Godot Version
Windows 11, Godot 4.2.1
Question
A RigidBody2D rests on top of a StaticBody2D. A ShapeCast2D is pointed down from the RigidBody. Calling is_colliding()
on the ShapeCast2D returns true
. Why does get_closest_collision_safe_fraction()
return a value of 1
?
Here’s the docs entry on get_closest_collision_safe_fraction()
:
The fraction from the ShapeCast2D 's origin to its target_position (between 0 and 1) of how far the shape can move without triggering a collision.
My understanding of this is that a 1
means that moving the full length of the ShapeCast would trigger no collisions and a 0
means the shape can not move at all without triggering collisions. So if is_colliding()
is true, how can get_closest_collision_safe_fraction()
be any value above 0
? Does get_closest_collision_safe_fraction()
ignore any object that the shape is already colliding with at its origin?
Details on the two Bodies:
RigidBody2D is size 128x128 square
StaticBody2D is size 128x128 square
ShapeCast2D is child of the RigidBody2D, centered on it, and size 128x128. Target position is default value (0, 50).