RayCast2D¶
Inherits: Node2D < CanvasItem < Node < Object
Category: Core
Brief Description¶
Query the closest object intersecting a ray
Member Functions¶
void | add_exception ( Object node ) |
void | add_exception_rid ( RID rid ) |
void | clear_exceptions ( ) |
Vector2 | get_cast_to ( ) const |
Object | get_collider ( ) const |
int | get_collider_shape ( ) const |
Vector2 | get_collision_normal ( ) const |
Vector2 | get_collision_point ( ) const |
int | get_layer_mask ( ) const |
int | get_type_mask ( ) const |
bool | is_colliding ( ) const |
bool | is_enabled ( ) const |
void | remove_exception ( Object node ) |
void | remove_exception_rid ( RID rid ) |
void | set_cast_to ( Vector2 local_point ) |
void | set_enabled ( bool enabled ) |
void | set_layer_mask ( int mask ) |
void | set_type_mask ( int mask ) |
Description¶
A RayCast2D represents a line from its origin to its destination position cast_to
, it is used to query the 2D space in order to find the closest object intersecting with the ray.
Member Function Description¶
- void add_exception ( Object node )
Adds a collision exception so the ray does not report collisions with the specified node
.
- void add_exception_rid ( RID rid )
- void clear_exceptions ( )
Removes all collision exception for this ray.
- Vector2 get_cast_to ( ) const
Return the destination point of this ray object
- Object get_collider ( ) const
Return the closest object the ray is pointing to. Note that this does not consider the length of the vector, so you must also use is_colliding to check if the object returned is actually colliding with the ray.
- int get_collider_shape ( ) const
Returns the collision shape of the closest object the ray is pointing to.
- Vector2 get_collision_normal ( ) const
Returns the normal of the intersecting object shape face containing the collision point.
- Vector2 get_collision_point ( ) const
Returns the collision point in which the ray intersects the closest object.
- int get_layer_mask ( ) const
Returns the layer mask for this ray.
- int get_type_mask ( ) const
- bool is_colliding ( ) const
Return whether the closest object the ray is pointing to is colliding with the vector (considering the vector length).
- bool is_enabled ( ) const
Returns whether this raycast is enabled or not
- void remove_exception ( Object node )
Removes a collision exception so the ray does report collisions with the specified node
.
- void remove_exception_rid ( RID rid )
- void set_cast_to ( Vector2 local_point )
Sets the ray destination point, so that the ray will test from the ray’s origin to local_point
- void set_enabled ( bool enabled )
Enables the RayCast2D. Only enabled raycasts will be able to query the space and report collisions.
- void set_layer_mask ( int mask )
- void set_type_mask ( int mask )