PhysicsBody2D

Hereda: CollisionObject2D < Node2D < CanvasItem < Node < Object

Heredado por: CharacterBody2D, RigidBody2D, StaticBody2D

Clase base abstracta para objetos de juego 2D afectados por la física.

Descripción

PhysicsBody2D es una clase base abstracta para objetos de juego 2D afectados por la física. Todos los cuerpos físicos 2D heredan de ella.

Tutoriales

Propiedades

bool

input_pickable

false (overrides CollisionObject2D)

Métodos

void

add_collision_exception_with(body: Node)

Array[PhysicsBody2D]

get_collision_exceptions()

Vector2

get_gravity() const

KinematicCollision2D

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

void

remove_collision_exception_with(body: Node)

bool

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


Descripciones de Métodos

void add_collision_exception_with(body: Node) 🔗

Añade un cuerpo a la lista de cuerpos con los que este cuerpo no puede colisionar.


Array[PhysicsBody2D] get_collision_exceptions() 🔗

Devuelve un conjunto de nodos que se añadieron como excepciones de colisión para este cuerpo.


Vector2 get_gravity() const 🔗

Devuelve el vector de gravedad calculado a partir de todas las fuentes que pueden afectar al cuerpo, incluyendo todas las anulaciones de gravedad de los nodos Area2D y la gravedad global del mundo.


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

Moves the body along the vector motion. In order to be frame rate independent in Node._physics_process() or Node._process(), motion should be computed using delta.

Returns a KinematicCollision2D, 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 CharacterBody2D.safe_margin for more details).

If recovery_as_collision is true, any depenetration from the recovery phase is also reported as a collision; this is used e.g. by CharacterBody2D for improving floor detection during floor snapping.


void remove_collision_exception_with(body: Node) 🔗

Quita un cuerpo de la lista de cuerpos con los que este cuerpo no puede colisionar.


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

Checks for collisions without moving the body. In order to be frame rate independent in Node._physics_process() or Node._process(), motion should be computed using delta.

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

collision is an optional object of type KinematicCollision2D, 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 CharacterBody2D.safe_margin for more details).

If recovery_as_collision is true, any depenetration from the recovery phase is also reported as a collision; this is useful for checking whether the body would touch any other bodies.