Question by
Srijan69titaniun · Dec 27, 2020 at 11:08 AM ·
2drpg
Disable Diagonal Movement
Hi, I'm very new to unity and C# programming. I have made a game (beginning) by following a tutorial on youtube and he didn't disabled the diagonal movements because he wanted them but I don't. So I have no idea how to do that.
public class PlayerControllerv2 : MonoBehaviour
{
private Rigidbody2D myRB;
[SerializeField]
private float speed;
void Start()
{
myRB = GetComponent<Rigidbody2D>();
}
// Update is called once per frame
void Update()
{
myRB.velocity = new Vector2(Input.GetAxisRaw("Horizontal")*speed*Time.deltaTime,Input.GetAxisRaw("Vertical") * speed * Time.deltaTime);
}
}
Comment
Your answer
Follow this Question
Related Questions
2D player hides behind the room setting 2 Answers
Designing 2D Level suggestion 0 Answers
Change Scenes Like Minit 1 Answer
How to fix the rotation bug? 1 Answer
8 direction movement with mouse 0 Answers