PhysicsBody3D

Inherits: CollisionObject3D < Node3D < Node < Object

Inherited By: CharacterBody3D, PhysicalBone3D, RigidDynamicBody3D, StaticBody3D

Base class for all objects affected by physics in 3D space.

Description

PhysicsBody3D is an abstract base class for implementing a physics body. All *Body types inherit from it.

Methods

void

add_collision_exception_with ( Node body )

bool

get_axis_lock ( BodyAxis axis ) const

PhysicsBody3D[]

get_collision_exceptions ( )

KinematicCollision3D

move_and_collide ( Vector3 linear_velocity, bool test_only=false, float safe_margin=0.001, int max_collisions=1 )

void

remove_collision_exception_with ( Node body )

void

set_axis_lock ( BodyAxis axis, bool lock )

bool

test_move ( Transform3D from, Vector3 linear_velocity, KinematicCollision3D collision=null, float safe_margin=0.001, int max_collisions=1 )

Property Descriptions

  • bool axis_lock_angular_x

Default

false

Setter

set_axis_lock(value)

Getter

get_axis_lock()

Lock the body's rotation in the X axis.


  • bool axis_lock_angular_y

Default

false

Setter

set_axis_lock(value)

Getter

get_axis_lock()

Lock the body's rotation in the Y axis.


  • bool axis_lock_angular_z

Default

false

Setter

set_axis_lock(value)

Getter

get_axis_lock()

Lock the body's rotation in the Z axis.


  • bool axis_lock_linear_x

Default

false

Setter

set_axis_lock(value)

Getter

get_axis_lock()

Lock the body's linear movement in the X axis.


  • bool axis_lock_linear_y

Default

false

Setter

set_axis_lock(value)

Getter

get_axis_lock()

Lock the body's linear movement in the Y axis.


  • bool axis_lock_linear_z

Default

false

Setter

set_axis_lock(value)

Getter

get_axis_lock()

Lock the body's linear movement in the Z axis.

Method Descriptions

  • void add_collision_exception_with ( Node body )

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


Returns true if the specified linear or rotational axis is locked.


Returns an array of nodes that were added as collision exceptions for this body.


Moves the body along the vector linear_velocity. This method should be used in Node._physics_process (or in a method called by Node._physics_process), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.

The body will stop if it collides. Returns a KinematicCollision3D, which contains information about the collision when stopped, or when touching another body along the motion.

If test_only is true, the body does not move but the would-be collision information is given.

safe_margin is the extra margin used for collision recovery (see CharacterBody3D.collision/safe_margin for more details).

max_collisions allows to retrieve more than one collision result.


  • void remove_collision_exception_with ( Node body )

Removes a body from the list of bodies that this body can't collide with.


Locks or unlocks the specified linear or rotational axis depending on the value of lock.


Checks for collisions without moving the body. This method should be used in Node._physics_process (or in a method called by Node._physics_process), as it uses the physics step's delta value automatically in calculations. Otherwise, the simulation will run at an incorrect speed.

Virtually sets the node's position, scale and rotation to that of the given Transform3D, then tries to move the body along the vector linear_velocity. Returns true if a collision would stop the body from moving along the whole path.

collision is an optional object of type KinematicCollision3D, which contains additional information about the collision when stopped, or when touching another body along the motion.

safe_margin is the extra margin used for collision recovery (see CharacterBody3D.collision/safe_margin for more details).

max_collisions allows to retrieve more than one collision result.