ShapeCast3D

Hereda: Node3D < Node < Object

Una forma 3D que barre una región del espacio para detectar CollisionObject3Ds.

Descripción

Shape casting allows to detect collision objects by sweeping its shape along the cast direction determined by target_position. This is similar to RayCast3D, but it allows for sweeping a region of space, rather than just a straight line. ShapeCast3D can detect multiple collision objects. It is useful for things like wide laser beams or snapping a simple shape to a floor.

Immediate collision overlaps can be done with the target_position set to Vector3(0, 0, 0) and by calling force_shapecast_update() within the same physics frame. This helps to overcome some limitations of Area3D when used as an instantaneous detection area, as collision information isn't immediately available to it.

Note: Shape casting is more computationally expensive than ray casting.

Propiedades

bool

collide_with_areas

false

bool

collide_with_bodies

true

int

collision_mask

1

Array

collision_result

[]

Color

debug_shape_custom_color

Color(0, 0, 0, 1)

bool

enabled

true

bool

exclude_parent

true

float

margin

0.0

int

max_results

32

Shape3D

shape

Vector3

target_position

Vector3(0, -1, 0)

Métodos

void

add_exception(node: CollisionObject3D)

void

add_exception_rid(rid: RID)

void

clear_exceptions()

void

force_shapecast_update()

float

get_closest_collision_safe_fraction() const

float

get_closest_collision_unsafe_fraction() const

Object

get_collider(index: int) const

RID

get_collider_rid(index: int) const

int

get_collider_shape(index: int) const

int

get_collision_count() const

bool

get_collision_mask_value(layer_number: int) const

Vector3

get_collision_normal(index: int) const

Vector3

get_collision_point(index: int) const

bool

is_colliding() const

void

remove_exception(node: CollisionObject3D)

void

remove_exception_rid(rid: RID)

void

resource_changed(resource: Resource)

void

set_collision_mask_value(layer_number: int, value: bool)


Descripciones de Propiedades

bool collide_with_areas = false 🔗

  • void set_collide_with_areas(value: bool)

  • bool is_collide_with_areas_enabled()

Si es true, se informará de las colisiones con Area3Ds.


bool collide_with_bodies = true 🔗

  • void set_collide_with_bodies(value: bool)

  • bool is_collide_with_bodies_enabled()

Si es true, se informará de las colisiones con PhysicsBody3Ds.


int collision_mask = 1 🔗

  • void set_collision_mask(value: int)

  • int get_collision_mask()

The shape's collision mask. Only objects in at least one collision layer enabled in the mask will be detected. See Collision layers and masks in the documentation for more information.


Array collision_result = [] 🔗

  • Array get_collision_result()

Devuelve la información completa de la colisión del barrido de colisión. Los datos devueltos son los mismos que en el método PhysicsDirectSpaceState3D.get_rest_info().


Color debug_shape_custom_color = Color(0, 0, 0, 1) 🔗

  • void set_debug_shape_custom_color(value: Color)

  • Color get_debug_shape_custom_color()

El color personalizado para usar para dibujar la forma en el editor y en tiempo de ejecución si Visible Collision Shapes está habilitado en el menú Depurar. Este color se resaltará en tiempo de ejecución si el ShapeCast3D está colisionando con algo.

Si se establece en Color(0.0, 0.0, 0.0) (por defecto), se utiliza el color establecido en ProjectSettings.debug/shapes/collision/shape_color.


bool enabled = true 🔗

  • void set_enabled(value: bool)

  • bool is_enabled()

Si es true, se informará de las colisiones.


bool exclude_parent = true 🔗

  • void set_exclude_parent_body(value: bool)

  • bool get_exclude_parent_body()

Si es true, el nodo padre será excluido de la detección de colisiones.


float margin = 0.0 🔗

  • void set_margin(value: float)

  • float get_margin()

El margen de colisión de la forma. Un margen más grande ayuda a detectar colisiones de forma más consistente, a costa de la precisión.


int max_results = 32 🔗

  • void set_max_results(value: int)

  • int get_max_results()

El número de intersecciones se puede limitar con este parámetro, para reducir el tiempo de procesamiento.


Shape3D shape 🔗

La forma que se usará para las consultas de colisión.


Vector3 target_position = Vector3(0, -1, 0) 🔗

  • void set_target_position(value: Vector3)

  • Vector3 get_target_position()

El punto de destino de la forma, relativo a la Node3D.position de este nodo.


Descripciones de Métodos

void add_exception(node: CollisionObject3D) 🔗

Añade una excepción de colisión para que la forma no reporte colisiones con el nodo especificado.


void add_exception_rid(rid: RID) 🔗

Añade una excepción de colisión para que la forma no reporte colisiones con el RID especificado.


void clear_exceptions() 🔗

Elimina todas las excepciones de colisión para esta forma.


void force_shapecast_update() 🔗

Updates the collision information for the shape immediately, without waiting for the next _physics_process call. Use this method, for example, when the shape or its parent has changed state.

Note: Setting enabled to true is not required for this to work.


float get_closest_collision_safe_fraction() const 🔗

Returns the fraction from this cast's origin to its target_position of how far the shape can move without triggering a collision, as a value between 0.0 and 1.0.


float get_closest_collision_unsafe_fraction() const 🔗

Returns the fraction from this cast's origin to its target_position of how far the shape must move to trigger a collision, as a value between 0.0 and 1.0.

In ideal conditions this would be the same as get_closest_collision_safe_fraction(), however shape casting is calculated in discrete steps, so the precise point of collision can occur between two calculated positions.


Object get_collider(index: int) const 🔗

Returns the collided Object of one of the multiple collisions at index, or null if no object is intersecting the shape (i.e. is_colliding() returns false).


RID get_collider_rid(index: int) const 🔗

Returns the RID of the collided object of one of the multiple collisions at index.


int get_collider_shape(index: int) const 🔗

Returns the shape ID of the colliding shape of one of the multiple collisions at index, or 0 if no object is intersecting the shape (i.e. is_colliding() returns false).


int get_collision_count() const 🔗

El número de colisiones detectadas en el punto de impacto. Utiliza esto para iterar sobre múltiples colisiones como las proporcionadas por los métodos get_collider(), get_collider_shape(), get_collision_point() y get_collision_normal().


bool get_collision_mask_value(layer_number: int) const 🔗

Devuelve si la capa especificada de collision_mask está habilitada o no, dado un layer_number entre 1 y 32.


Vector3 get_collision_normal(index: int) const 🔗

Devuelve la normal de una de las múltiples colisiones en index del objeto que se interseca.


Vector3 get_collision_point(index: int) const 🔗

Devuelve el punto de colisión de una de las múltiples colisiones en index donde la forma se interseca con el objeto que colisiona.

Nota: Este punto está en el sistema de coordenadas global.


bool is_colliding() const 🔗

Returns whether any object is intersecting with the shape's vector (considering the vector length).


void remove_exception(node: CollisionObject3D) 🔗

Removes a collision exception so the shape does report collisions with the specified node.


void remove_exception_rid(rid: RID) 🔗

Removes a collision exception so the shape does report collisions with the specified RID.


void resource_changed(resource: Resource) 🔗

Obsoleto: Use Resource.changed instead.

Este método no hace nada.


void set_collision_mask_value(layer_number: int, value: bool) 🔗

Basado en value, habilita o deshabilita la capa especificada en collision_mask, dado un layer_number entre 1 y 32.