Pick an object and set its Body in the inspector: Static (walls, floors, slopes, one-way platforms, moving platforms), Character (moves with move_and_slide()) or Area (notices what enters and leaves). Each body has collision layers (what it is) and a mask (what it collides with or notices), named on Game Options > Collision (⌃⌥⌘T), and a shape: the sprite's mask, a rectangle, a circle, a capsule or a polygon (x,y x,y … from the origin).
velocity_x = input_axis("move_x") * run_speed;
if (!is_on_floor()) velocity_y += fall_gravity * studio_delta();
if (is_on_floor() && input_pressed("jump")) velocity_y = -jump_speed;
move_and_slide();
move_and_slide()slides along walls, stands on slopes up to Floor angle without sliding down, keeps to the floor over bumps and down slopes (Floor snap), rides moving platforms and lands on one-way platforms from above only.- After it:
is_on_floor(),is_on_wall(),is_on_ceiling(),get_floor_normal(),get_floor_angle(),get_slide_collision(i). body_move_and_collide(dx, dy)stops at the first thing in the way;raycast(x1, y1, x2, y2)finds the first body or tile on a line.- Tile maps collide when their tile set has shapes (drawn in the tile set editor's Collision mode, or on the Collision page: full, slopes, half tiles, one way, or points).
- With one instance selected in the room, its shape has handles to drag (see "Body shape handles in the room").
- Code > Kit > Show Collision Shapes When Playing (⌃⌥⌘D), or F3 in the game, draws every shape.
Related topics
Keys are shown as on the Mac: ⌘ Command, ⌥ Option, ⌃ Control, ⇧ Shift. Studio for Windows shows its own keys beside each menu item.