Hello, i’m learning to use unity and i’m trying to make a simple scene in wich you move a block over a quad with a first person camera. I almost achieve it, but i don’t know how to make the block move in different directions at the same time. Like if you press ‘w’ and ‘a’ it moves forward and left at the same time (diagonally).
This is all the code: ... - Imgur
I would like to know if this is the correct way to do it too, if possible. Thanks.
Use the code tags when posting code. Using code tags properly - Unity Engine - Unity Discussions
And perhaps you could do something like this.
float x=0;
float z=0;
if (Input.GetKey(KeyCode.W))
x=1;
if (Input.GetKey(KeyCode.S))
x=-1;
if (Input.GetKey(KeyCode.A))
z=1;
if (Input.GetKey(KeyCode.D))
z=-1;
transform.rigidbody.velocity=transform.TransformDirection(new Vector3(x, 0, z));