Unity Example (3D)
You must either name your new script PlayerMovement.cs OR update this code after the word "class" to the name of your script.
This is code that uses WASD kets to move the object the script is added to.
It also rotates left and right using the arrow keys and jumps with the space bar.
For jump to work, be sure to add a Rigidbody component to the object. If the object falls over, in the Rigidbody component, free the X and Z rotations.
This code uses shortcuts. (See below the code.)
Vector3 Shortcuts:
Shortcut | Equivalent |
|
|
|
|
|
|
|
|
|
|
|
|
These can be multiplied and divided as an easy way to adjust the value on just one axis.
Last updated