Physics
Table of Contents
Collision Objects, Layers and Masks discussion
All following classes inherit CollisionObject2D
:
Area2D
- can detect when objects overlap and can emit signals when bodies enter or exit
- can override physics properties such as gravity or damping in a defined area.
- A
StaticBody2D
- Participates in collision detection, but does not move in response to the collision
RigidBody2D
- Do not control a RigidBody2D directly, but instead you apply forces to it
- You can handle collisions by connecting callback functions to signals like
body_entered
.
KinematicBody2D
- A body that provides collision detection, but no physics.
- All movement and collision response must be implemented in code.
- There is no such thing as signals like
body_entered
. - Instead, you should use
move_and_collide
and investigate its return value,KinematicCollision2D
.
To define collision bounds, you can add any number of CollisionShape2D
or CollisionPolygon2D
as child nodes.

When changing sizing the collision shape, you should always use the size handles, not the Node2D scale handles. Scaling a shape can result in unexpected collision behavior.
You can define collision layers to categorize collision objects. To exploit collision layers, you should configure collision masks for each object.

player
should collide with walls
, enemies
, coins
, but not with itself.- https://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html#collision-objects
- https://docs.godotengine.org/en/3.0/tutorials/physics/physics_introduction.html#collision-layers-and-masks
- https://docs.godotengine.org/en/3.0/classes/class_kinematiccollision2d.html#class-kinematiccollision2d