Godot – Platform Game Tutorial 1
To be very clear, I did not make this tutorial and all credit for it goes to Heartbeast.
The first tutorial focus’s on the simple movement of a sprite on screen. The players character is created by using a KinematicBody node with a Sprite and a CollisionShape2D.
A KinematicBody2D is a body that can be controlled by the player in a 2D setting, it’s designed to have no physics by default but can easily have features like gravity implemented. They are very useful when you want a body to collide with another without adverse affects from physics.
A Sprite is a node that displays a 2D texture. For example, in order for your character on screen to have a face etc, you will need to upload a JPG or PNG image to the sprite node.
A CollisionShape2D is a node that allows your Body and Sprite to collide and bump into things within your game. It essentially creates a shape of your choice in the area of the Body so the Body won’t fall through the floor or walk through walls.
As the tutorial suggested, I used the default icon for the players sprite and then used it again but blacked it out to create walls for the character to move across. The wall was made out of a StaticBody2D, Sprite and a CollisionShape2D.
A StaticBody2D is a body that is not intended to move at all. These nodes are generally used for environments and walls. CollisionShape2Ds and Sprites can also be applied to these nodes.
The code for moving the body is very simple, for example, if I wanted to move the character right I’d write something like:
motion.x = 100
This essentially says if the button mapped to “ui_right” is pressed, then the body will move +100 pixels along the X axis. If it was motion.x = -100, then it would move the opposite direction. The “ui_right” input was mapped to the right arrow key.
The tutorial also teaches you how to make your character jump by adding gravity in the game and creating code similar to moving left and right but simply changing the axis to y. The image below shows me playing around and without gravity to create an object that can move on all axis, one step closer to creating space like conditions.
Godot – Platform Game Tutorial 2
The second tutorial teaches you how to animate Sprites in the engine and create a Tileset.
You star by creating a new screen with