Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

ShapeCast3D

Inherits: Node3D < Node < Object

A 3D shape that sweeps a region of space to detect CollisionObject3Ds.

Description

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.

Properties

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)

Methods

void

add_exception ( CollisionObject3D node )

void

add_exception_rid ( RID rid )

void

clear_exceptions ( )

void

force_shapecast_update ( )

float

get_closest_collision_safe_fraction ( ) const