Rigidbody habits do not map one-to-one to CharacterBody2D.
Physics Guide
Choose the right body type, collision layer, and movement API before tuning feel.
⚡ Physics Bodies Guide
Understanding Godot's physics system - for Unity developers
🏃 CharacterBody2D
Use for: Player characters, NPCs, enemiesLike a Rigidbody2D with CharacterController behavior. You control
movement directly, but get collision detection.
The Two Movement Methods
move_and_slide()
Automatically slides along collision surfaces. Best for most games.
- Handles slopes
- Provides
is_on_floor(),is_on_wall() - Modifies
velocityfor you
move_and_collide()
Stops on collision, returns collision info. Best for custom physics.
- Returns
KinematicCollision2D - You handle the response
- Good for bouncing, custom sliding
Platformer Movement (Complete Example)
extends CharacterBody2D
var speed = 300.0
var jump_force = -400.0
# Get gravity from project settings
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
func _physics_process(delta):
# Apply gravity every frame
velocity.y += gravity * delta
# Get horizontal input (-1, 0, or 1)
var direction = Input.get_axis("move_left", "move_right")
velocity.x = direction * speed
# Jump only when on floor
if Input.is_action_just_pressed("jump") and is_on_floor():
velocity.y = jump_force
# Move and handle collisions
move_and_slide()Top-Down Movement
extends CharacterBody2D
var speed = 200.0
func _physics_process(delta):
# Get direction from all 4 movement keys
var direction = Input.get_vector(
"move_left", "move_right",
"move_up", "move_down"
)
velocity = direction * speed
move_and_slide()- Always use
_physics_process()for movement, not_process() is_on_floor()only works after callingmove_and_slide()- Set
floor_max_angleto control what counts as a "floor"
Lock the pattern in
Before jumping to the next page, turn the idea into one tiny scene or script. That is where the Godot habit sticks.
Character movement is less prebuilt, but more explicit and scriptable.
Use CharacterBody for controlled actors, RigidBody for simulation, Area for detection.
Build a collision layer chart for player, enemy, world, trigger, and pickup.