Physics Body Types
Godot provides four main 2D physics body types, each suited for different use cases:RigidBody2D
Physics-simulated bodies affected by gravity, forces, and collisions.Basic Setup
Applying Forces
Velocity Control
Damping
Collision Detection
Custom Integration
CharacterBody2D
Best for player and AI-controlled characters with precise movement control.Basic Movement
Collision Detection
Getting Collision Information
Platformer Movement Settings
Wall Jumping
Platform Movement
StaticBody2D
Immovable bodies for walls, floors, and obstacles.constant_linear_velocity doesn’t move the body but affects touching bodies as if it were moving.AnimatableBody2D
For moving platforms and animated obstacles.Collision Shapes
All physics bodies need collision shapes:Common Shape Types
RectangleShape2D- Rectangles and squaresCircleShape2D- CirclesCapsuleShape2D- Capsules (good for characters)ConvexPolygonShape2D- Convex polygonsConcavePolygonShape2D- Concave polygons (static only)
Physics Layers and Masks
Control which objects collide with each other:Layer Examples
Raycasting
RayCast2D Node
PhysicsRayQueryParameters2D
Area2D
Detect overlaps without physics simulation:Manual Overlap Detection
Physics Material
Control friction and bounce:Best Practices
Use CharacterBody2D for player control
Use CharacterBody2D for player control
CharacterBody2D provides better control and is deterministic, perfect for player characters.Use RigidBody2D for physics objects
Use RigidBody2D for physics objects
Objects that should react realistically to forces like crates, balls, and ragdolls.
Set up physics layers properly
Set up physics layers properly
Properly configured layers prevent unnecessary collision checks and improve performance.
Enable contact monitoring only when needed
Enable contact monitoring only when needed
On
RigidBody2D, only enable contact_monitor when you need collision signals to save performance.Next Steps
TileMaps
Add physics to tile-based levels
Canvas Layers
Organize your game’s visual layers