Multiply the dir vector x and z by the move_speed variable
The model always stares at the camera.
Code it to rotate in the movement direction.
Note that x and y are reversed.
This is because we want the y value rotation
Therefore y value comes first.
Y value is the horizontal rotation
Look at the Green line around the player
To prevent the model snapping back
Code it to only rotate if we are moving.
Player now remains facing current position
To make the animations look
smoother we will lerp the angle.
Lerp stands for Linear Interpolation
it essentially fills in the missing
numbers between two values.
This creates a smoothmotion
rather than jumping from one value to the next.
The lerp_angle() method needs 3 parameters:
The amount to add each step
Use the built-in method to check if the player is on the floor.
Simulate gravity pulling them down when they are not on
Testing shows that we can jump, fall back to ground and cannot jump while in the air
If player is on floor and pressing jump key
We let them jump (change their y velocity by jump force)
Create a game_over function
In the _physics_process function
Check when the player falls off the platform
call the game_over function
Drag the Player Node into the FileSystem to save it as it's own Scene
Alternatively right-click on it and select Save Branch as Scene