Collisions
With our brand-new camera in place, let’s take a look at collisions. For now, we have the visuals of a nice arena, including walls and rocks, but they don’t really act like them. The player character is able to just run through them as if they were made out of air instead of solid matter.
Just like with the movement of the player, we can solve this using the built-in physics engine. Let’s start by taking a look at the different physics bodies at our disposal.
The different physics bodies
For the player character, we used the CharacterBody2D physics body. But this is not the only kind that comes with the physics engine Godot. There are a few other ones:
Figure 9.8 – The three different physics bodies as displayed in the scene tree
For 2D games, there are three different kinds of physics bodies available. Each has its own uses within a game or physics simulation. Let’s take a look at each.