In this video, we set up collisions around our character to see how
the KinematicBody2D.move_and_slide()
function allows us to
collide with the environment.
We also take this opportunity to test the
node.The
node allows you to draw collision polygons. Unlike the node, you’re not limited to predefined geometric shapes. Instead, you create your own shapes.This freedom comes at a potential performance cost, so we recommend using the
node whenever you don’t need a .To change your polygon, select the
node and, in the toolbar at the top, click the icons to change the drawing tool.There are three tools:
You can use the 2D grid and snapping to draw horizontal and vertical lines with your collision polygon. To turn on grid snapping, press Shift+G or click the icon with a magnet in the toolbar.
To configure the grid’s spacing, click the vertical three dots in the toolbar, then Configure Snap…
Open the practice Bumping in walls.
In the next series, we’ll learn about Procedural Content Generation (PCG).
Best of luck with the practice, and we’ll see you in the next chapter.