Answer the question
In order to leave comments, you need to log in
How to make a character in unity2d move the other way?
How to change the character controller so that it moves along the x axis?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Player : MonoBehaviour
{
private Vector2 targetPos;
public float Yincrement;
private void Update()
{
if(Input.GetKeyDown(KeyCode.W))
{
targetPos = new Vector2(transform.position.x, transform.position.y + Yincrement);
transform.position = targetPos;
}
else if(Input.GetKeyDown(KeyCode.S))
{
targetPos = new Vector2(transform.position.x, transform.position.y + Yincrement);
transform.position = targetPos;
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question