See all glossary terms

Collisions

In games, a collision refers to when two in-game objects touch one another or overlap in a way that the game needs to recognize.
We use collisions mainly to:
  • Prevent objects from moving through each other.
  • Trigger events and interactions like picking up a power-up, taking damage from an enemy, or talking to a non-playable character.
  • Simulate realistic interactions. For example, to simulate a character or object being projected by an explosion.

Collisions use simple geometry

Collisions rely on simple and invisible geometry to save on performance. They don't directly use the 3d models and sprites the player sees.
While the computer can display and shade millions of polygons in each frame, physics calculations are much more expensive. So, we use a simplified representation of the game world for physics.
We often work with basic geometric shapes like circles, rectangles, capsules, or planes. When we need to match the shape of a sprite or 3D model closely, we also use hand-crafted polygons and 3D meshes. The more detailed these hand-crafted shapes are, the more performance they cost.

Physics nodes and collision shapes

In game engines, not all entities have collision support. Generally, we use specific components to tell the physics engine which entities should support collisions and how they should behave.
We typically use one of the physics nodes in Godot for this purpose. They mainly are:
  • Area3D, StaticBody3D, RigidBody3D, and CharacterBody3D in 3D.
  • Area2D, StaticBody2D, RigidBody2D, and CharacterBody2D in 2D.
To be precise, all the nodes that inherit from CollisionObject and CollisionObject2D support collisions. We pair them with one or more collision nodes to define their collision geometry:
  • CollisionShape3D and CollisionPolygon3D in 3D.
  • CollisionShape2D and CollisionPolygon2D in 2D.

See Also

Related terms in the Glossary