summaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2023-10-21 17:23:07 +0200
committerA Thousand Ships <96648715+AThousandShips@users.noreply.github.com>2024-04-07 11:42:30 +0200
commitf2d4ff5c1f3ae4382f08497dd0b669bbe2e3c513 (patch)
tree2114e0f2d703ce503b1f66b259f212a9c6392c1a /doc
parente5b4ef8e9522e950033cbece39a31a4a76da19c1 (diff)
downloadredot-engine-f2d4ff5c1f3ae4382f08497dd0b669bbe2e3c513.tar.gz
Add instructions to get shape of `RayCast2D/3D`
Adds details on how to get the intersected shape
Diffstat (limited to 'doc')
-rw-r--r--doc/classes/RayCast2D.xml15
-rw-r--r--doc/classes/RayCast3D.xml15
2 files changed, 30 insertions, 0 deletions
diff --git a/doc/classes/RayCast2D.xml b/doc/classes/RayCast2D.xml
index 31daaab417..16643b0a71 100644
--- a/doc/classes/RayCast2D.xml
+++ b/doc/classes/RayCast2D.xml
@@ -56,6 +56,21 @@
<return type="int" />
<description>
Returns the shape ID of the first object that the ray intersects, or [code]0[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
+ To get the intersected shape node, for a [CollisionObject2D] target, use:
+ [codeblocks]
+ [gdscript]
+ var target = get_collider() # A CollisionObject2D.
+ var shape_id = get_collider_shape() # The shape index in the collider.
+ var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider.
+ var shape = target.shape_owner_get_owner(owner_id)
+ [/gdscript]
+ [csharp]
+ var target = (CollisionObject2D)GetCollider(); // A CollisionObject2D.
+ var shapeId = GetColliderShape(); // The shape index in the collider.
+ var ownerId = target.ShapeFindOwner(shapeId); // The owner ID in the collider.
+ var shape = target.ShapeOwnerGetOwner(ownerId);
+ [/csharp]
+ [/codeblocks]
</description>
</method>
<method name="get_collision_mask_value" qualifiers="const">
diff --git a/doc/classes/RayCast3D.xml b/doc/classes/RayCast3D.xml
index f9f94e5cfc..6a4c40d227 100644
--- a/doc/classes/RayCast3D.xml
+++ b/doc/classes/RayCast3D.xml
@@ -57,6 +57,21 @@
<return type="int" />
<description>
Returns the shape ID of the first object that the ray intersects, or [code]0[/code] if no object is intersecting the ray (i.e. [method is_colliding] returns [code]false[/code]).
+ To get the intersected shape node, for a [CollisionObject3D] target, use:
+ [codeblocks]
+ [gdscript]
+ var target = get_collider() # A CollisionObject3D.
+ var shape_id = get_collider_shape() # The shape index in the collider.
+ var owner_id = target.shape_find_owner(shape_id) # The owner ID in the collider.
+ var shape = target.shape_owner_get_owner(owner_id)
+ [/gdscript]
+ [csharp]
+ var target = (CollisionObject3D)GetCollider(); // A CollisionObject3D.
+ var shapeId = GetColliderShape(); // The shape index in the collider.
+ var ownerId = target.ShapeFindOwner(shapeId); // The owner ID in the collider.
+ var shape = target.ShapeOwnerGetOwner(ownerId);
+ [/csharp]
+ [/codeblocks]
</description>
</method>
<method name="get_collision_face_index" qualifiers="const">