From 6bc0be16a54862af2f75c8ed12109c079349ad17 Mon Sep 17 00:00:00 2001 From: Paul Joannon Date: Sun, 14 Aug 2022 10:09:35 +0200 Subject: Expose the collider RID in Raycast nodes Create and expose the method `get_collider_rid` in `RayCast2D` and `Raycast3D`. This method returns the `RID` of the first object that the ray intersects, or an empty `RID` if no object is intersecting the fay (i.e. `is_colliding` returns `false`). --- scene/2d/ray_cast_2d.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'scene/2d/ray_cast_2d.h') diff --git a/scene/2d/ray_cast_2d.h b/scene/2d/ray_cast_2d.h index 1fb97d89fe..57f993fe8d 100644 --- a/scene/2d/ray_cast_2d.h +++ b/scene/2d/ray_cast_2d.h @@ -41,6 +41,7 @@ class RayCast2D : public Node2D { bool enabled = true; bool collided = false; ObjectID against; + RID against_rid; int against_shape = 0; Vector2 collision_point; Vector2 collision_normal; @@ -91,6 +92,7 @@ public: bool is_colliding() const; Object *get_collider() const; + RID get_collider_rid() const; int get_collider_shape() const; Vector2 get_collision_point() const; Vector2 get_collision_normal() const; -- cgit v1.2.3