Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

PhysicsBody2D

Inherits: CollisionObject2D < Node2D < CanvasItem < Node < Object

Inherited By: CharacterBody2D, RigidBody2D, StaticBody2D

Abstract base class for 2D game objects affected by physics.

Description

PhysicsBody2D is an abstract base class for 2D game objects affected by physics. All 2D physics bodies inherit from it.

Tutorials

Properties

bool

input_pickable

false (overrides CollisionObject2D)

Methods

void

add_collision_exception_with ( Node body )

PhysicsBody2D[]

get_collision_exceptions ( )

KinematicCollision2D

move_and_collide ( Vector2 motion, bool test_only=false, float safe_margin=0.08, bool recovery_as_collision=false )

void

remove_collision_exception_with ( Node body )

bool

test_move ( Transform2D from, Vector2 motion, KinematicCollision2D collision=null, float safe_margin=0.08, bool recovery_as_collision=false )


Method Descriptions

void add_collision_exception_with ( Node body )

Adds a body to the list of bodies that this body can't collide with.


PhysicsBody2D[] get_collision_exceptions ( )

Returns an array of nodes that we