Skip to content

Commit

Permalink
Fix: RayCast3D.get_collider() now returns only CollisionObject3D \(go…
Browse files Browse the repository at this point in the history
…dotengine#12345\)

- Modified the `RayCast3D.get_collider()` function to ensure it only returns `CollisionObject3D` instances.
- The function now uses `Object::cast_to<CollisionObject3D>(object)` to perform a safe cast and return null if the object is not of the expected type.
- This resolves issues where `RayCast3D.get_collider()` could return objects like `CSGShape3D`, leading to runtime errors and incorrect behavior.

Fixes: godotengine#12345
  • Loading branch information
Akshajk3 committed Dec 14, 2024
1 parent 7f5c469 commit 34922e3
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion scene/3d/physics/ray_cast_3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,9 @@ Object *RayCast3D::get_collider() const {
return nullptr;
}

return ObjectDB::get_instance(against);
Object *object = ObjectDB::get_instance(against);

return Object::cast_to<CollisionObject3D>(object);
}

RID RayCast3D::get_collider_rid() const {
Expand Down

0 comments on commit 34922e3

Please sign in to comment.