You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A ray in 3D space, used to find the first CollisionObject3D it intersects.
Description
A raycast represents a ray from its origin to its target_position that finds the closest CollisionObject3D along its path, if it intersects any.
However, the method RayCast3D.get_collider returns an Object, not a CollectionObject3D as one would expect from the documentation.
Casting that Object to CollisionObject3D does not work with constructive solid geometry. Indeed, get_collider can return a CSGShape3D which cannot be cast to CollisionObject3D.
Steps to reproduce
Point a RayCast3D node at a nearby CSGBox3D.
Give the RayCast3D node a target_position that ensures it reaches the box.
Tick use_collision on the CSGBox3D node, under CSGShape3D.
Add this script to the RayCast3D node:
extends RayCast3D
func _physics_process(_delta: float) -> void:
var hovered_unclear := get_collider()
var hovered_collision_object_3D := hovered_unclear as CollisionObject3D
if (hovered_unclear and not hovered_collision_object_3D):
push_error("TypeError: RayCast3D.get_collider() returned a node that is not a CollisionObject3D")
assert(false) # Or place a break-point on the previous line.
See in the debugger that hovered_unclear is a GSGBox3D.
Tested versions
and probably everything before that.
System information
Godot v4.3.stable (77dcf97) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 2060 SUPER (NVIDIA; 32.0.15.6603) - Intel(R) Core(TM) i7-9700 CPU @ 3.00GHz (8 Threads)
Issue description
The documentation of
RayCast3D
makes it clear that it is meant to detect collisions withCollisionObject3D
:However, the method
RayCast3D.get_collider
returns anObject
, not aCollectionObject3D
as one would expect from the documentation.Casting that
Object
toCollisionObject3D
does not work with constructive solid geometry. Indeed,get_collider
can return aCSGShape3D
which cannot be cast toCollisionObject3D
.Steps to reproduce
RayCast3D
node at a nearbyCSGBox3D
.RayCast3D
node atarget_position
that ensures it reaches the box.use_collision
on theCSGBox3D
node, underCSGShape3D
.RayCast3D
node:hovered_unclear
is aGSGBox3D
.Minimal reproduction project (MRP)
raycast3d-get_collision.zip
The text was updated successfully, but these errors were encountered: