Up to date
This page is up to date for Godot 4.2
.
If you still find outdated information, please open an issue.
ShapeCast2D¶
Inherits: Node2D < CanvasItem < Node < Object
A 2D shape that sweeps a region of space to detect CollisionObject2Ds.
Description¶
Shape casting allows to detect collision objects by sweeping its shape along the cast direction determined by target_position. This is similar to RayCast2D, but it allows for sweeping a region of space, rather than just a straight line. ShapeCast2D 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 Vector2(0, 0)
and by calling force_shapecast_update within the same physics frame. This helps to overcome some limitations of Area2D 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.
Properties¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
void |
add_exception ( CollisionObject2D node ) |
void |
add_exception_rid ( RID rid ) |
void |
clear_exceptions ( ) |
void |
|
get_closest_collision_safe_fraction ( ) const |
|
get_closest_collision_unsafe_fraction ( ) const |
|
get_collider ( int index ) const |
|
get_collider_rid ( int index ) const |
|
get_collider_shape ( int index ) const |
|
get_collision_count ( ) const |
|
get_collision_mask_value ( int layer_number ) const |
|
get_collision_normal ( int index ) const |
|
get_collision_point ( int index ) const |
|
is_colliding ( ) const |
|
void |
remove_exception ( CollisionObject2D node ) |
void |
remove_exception_rid ( RID rid ) |
void |
set_collision_mask_value ( int layer_number, bool value ) |
Property Descriptions¶
bool collide_with_areas = false
If true
, collisions with Area2Ds will be reported.
bool collide_with_bodies = true
void set_collide_with_bodies ( bool value )