Add a Script to the CharacterBody2D node of the Player
Add a Script to the CharacterBody2D node of the Player
Enable the Basic Movement Template when creating the script
Enable the Basic Movement Template when creating the script
The default movement script is shown below
The default movement script is shown below
Clean up the code to make it readable and manageable
Clean up the code to make it readable and manageable
Do this by moving things into their own functions
Do this by moving things into their own functions
Call these functions in the process function
Call these functions in the process function
The function implementations are shown below
The function implementations are shown below
This script will enable basic character movement
This script will enable basic character movement
ENABLE COLLISIONS WITH THE GROUND AND PASS THROUGH LAYERS!
ENABLE COLLISIONS WITH THE GROUND AND PASS THROUGH LAYERS!
On the Collision Property of the CharacterBody2D
On the Collision Property of the CharacterBody2D
Turn ON Collision Mask layers 2 and 3
Turn ON Collision Mask layers 2 and 3
This is so that the Player on Collision Layer 1
This is so that the Player on Collision Layer 1
is looking for collisions on Layers 2 and 3
is looking for collisions on Layers 2 and 3
These are Ground and Pass_through Layers
These are Ground and Pass_through Layers
The Player can now collide with the Ground and Pass_through layers!
The Player can now collide with the Ground and Pass_through layers!
Remember to rename layers to help you:
Remember to rename layers to help you:
Go to Project --> Project Settings --> Layer Names --> 2D Physics
Go to Project --> Project Settings --> Layer Names --> 2D Physics
Save the Player Scene.
Save the Player Scene.
Drag and Drop it into Level_1
Drag and Drop it into Level_1
Test that the Player can move around the level.
Test that the Player can move around the level.
One-Way collision setting on the pass-through tiles we can jump UP THROUGH the platforms.
One-Way collision setting on the pass-through tiles we can jump UP THROUGH the platforms.