Game Development tutorials
Game Development  journey
Beginner "how to" tutorials , programming, software usage,  artwork, news  and more
For TIPS and SHORT TUTORIALS
 FOLLOW 
100+

How to show Collision Shapes in Godot Editor

Posted by Vix Mark on April 2No Comments
How to show collision shapes in Godot Editor
Monitoring collisions while debugging

CharacterBody2D, RigidBody2D and StaticBody2D Classes in Godot Engine all must have Collision Shapes to work properly. They all to some extent are affected by Physics Engine of the editor.

These bodies inherit from PhysicsBody2D Class which iself inherits from CollisionObject2D. Check out this screenshot:

PhysicsBody2D Class
PhysicsBody2D inheritance

So, when we add any of these physics bodies to our game it must have a collision shape around it to be able to push, bounce or make other physical interactions with other body type objects. In this tutorial I'll explain how to add shapes to the objects in the editor and how to turn on their visibility when we run our game in Godot Editor.

CONTENT:

How to add CollisionShape2D and set up new Shape in the Inspector dock

Assuming you have a scene with any of the body type mentioned or Area2D object a the top of your scene tree and you want to a CollisionShape2D object as its child, then set up the proper shape for the body. Now, add a new child to your scene and choose CollsionShape2D in the list of nodes, then click on it in the Scene dock, go to Inspector dock and add a new shape by choosing one of them in the list of the Shape's property value field.

Inspector - CollisionShape2D - Shape property

As you can see, I have CapsuleShape which can be used for shooting bullets, for example or other elliptically shaped objects. Among others there's also RectangleShape2D and CircleShape2D. These two are probably used the most often.

How to show Collision Shapes in Godot Editor

When we run our game in Godot Editor it doesn't show collision shapes around the objects because by default this option is set to false. There are 2 ways how you can change it:

  • with Godot's menu
  • with the script.

Make Collision Shapes visible with the menu

Click on Debug category in Godot's Main Menu (at the top). In the drop down Debug category items find Visible Collision Shapes, and check the checkbox next to it. That's it. Now, when you run your game in the editor you'll see colored collision shapes around the objects in the game.

Show Collision Shapes using GDScript

To turn on the visibility of the shapes we need to access the SceneTree object because this property belongs to the scene tree class. This is the list of properties existing in that class:

Scene Tree properties

In your Main Scene gdscript file in _ready() method write this line of code:
get_tree().debug_collisions_hint = true

This will have the same effect as making shapes visible with the main menu. Check out this demo:

Visible shapes demonstration

Here I have all 3 types of physics bodies. My player is CharacterBody2D, the ball is RigidBody2D and the rocks are StaticBody2D objects. As you can see, all of them have collision shapes and they are all visible in the editor.

By the way, if you want to learn more about different Classes in Godot Engine take a look at this tutorial about AnimatedSprite2D.

If you find this tutorial useful, follow me on Instagram for more tips and learning materials.

Share this
Pin it
Conversation
0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
©2026 GamaDevFcups - how to make Indie Games.

Game Development: Godot Engine, Krita, Blender, programming, tutorials

GameDevFcups

Desidned and built by VixStudio
 | 
VixMark@protonmail.com
pointer-down
0
Would love your thoughts, please comment.x
()
x