ShapeCast2D

A 2D shape that sweeps a region of space to detect CollisionObject2Ds.

ShapeCast2D.swift:22
class ShapeCast2D

Shape casting allows to detect collision objects by sweeping its shape along the cast direction determined by targetPosition. 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 targetPosition set to Vector2(0, 0) and by calling forceShapecastUpdate 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.