Create a new scene with CharacterBody3D as root
Add a MeshInstance3D and CollisionShape3D as children
It is a specialized physics node designed for player-controlled characters or NPCs, moving only when commanded by script. It provides built-in functions like move_and_slide() to handle movement, collisions, and slope/stair climbing without full physics simulation.
Select the MeshInstance3D
Adjust the height of the Mesh
By halving the y dimension
Add a New StandardMaterial3D
Change the Albedo to a bright colour
Select the CollisionShape3D
Adjust the size to match the mesh
Set the Collision Layer to 1 (player)
Set the Mask to Layers 2, 4 and 5
(Wall, Floor and Obstacle)
Add a script to the Player node
Add an export variable for the speed
Later we will make a finish line
Which will pause the game so
Set process mode to always
It is a node property that determines if a node (and its children) continues to operate, process script logic, and receive input when the scene tree is paused.
Register an input event for the restart key
Create a function to handle movement
Get the movement direction
Apply friction to slow down
Create a function to handle collisions
Loop through all the collisions
Extract the collision object
If the object is in the interactable group
Change the color when we collide
Finally in the physics process function
It is a fundamental method used for moving CharacterBody nodes (formerly KinematicBody) while handling collisions, slopes, and sliding along surfaces automatically. It uses the node's velocity property to calculate movement, handles delta time internally, and returns a new velocity vector to be used for future movement.
1. Step One: The Setup (Before move_and_slide) Everything that changes or calculates the player's intended speed and direction must happen first. You are essentially telling Godot, "Here is what I want to do this frame."
Reading player keyboard/controller inputs.
Applying gravity (e.g., velocity.y -= gravity * delta).
Adding knockback from an explosion.
2. Step Two: The Execution (move_and_slide()) Now you call the function. Godot takes that velocity you just calculated, moves the character through the 3D world, and handles all the complex math of bumping into walls, sliding down ramps, and stopping at the floor. Crucially, Godot modifies your velocity during this step (for example, if you run into a solid wall, Godot instantly sets your forward velocity to 0 so you don't pass through it).
3. Step Three: The Reaction (After move_and_slide) Everything that depends on what just happened during the movement must go here. If you put these checks before move_and_slide(), you are checking data from the previous frame, which causes buggy, delayed behavior.
Collision Checks: Like your handle_collisions() loop using get_slide_collision(). You can't know what you bumped into until you actually move!
State Checks: Functions like is_on_floor(), is_on_wall(), or is_on_ceiling(). These are updated entirely by move_and_slide(). If you want to play a "landing" dust particle effect when the player hits the ground, you must check is_on_floor() after moving.
Animations: If you want to change the player's animation to "falling" or "running," you usually do it after the movement is finalized.
Return to the Main Course Scene
Instance your Player Scene
Add a Camera3D as child of the Player Node
Test moving around in the scene