Get RID from objects that can have multiple collision shapes to exclude in PhysicsRayQueryParameters3D

Godot Version



In my game I place new conveyor modules and use ray casting to move them around the map

I want to exclude the already placed modules from the recasting. I have read that I can use

var query = PhysicsRayQueryParameters3D.create(start, end)
query.exclude = [modules]

but that requires that the array is a list of RIDs and not my actual nodes of all the modules.
What is the best way to get all the RIDs of all the modules in an array?

Or is there a better way to make sure that the ray cast is ignoring the already placed modules?


You can get the RID of a body with CollisionObject3D.get_rid()

1 Like

Yes but my nodules have multiple collision objects and as far as I can see there is nothing like get_all_collision_objects()

Does it make sense to assign them all to a group and then cycle over the same whole group for every call?

Do you mean that they have multiple collision shapes? Like a StaticBody3D with a bunch of CollisionShape3D or CollisionPolygon3D children? If that’s the case you won’t be able to filter them this way. Only bodies have a RID.

The returned Dictionary of PhysicsDirectSpaceState3D.intersect_ray() has the shape index of the intersection but that index is an internal one that may or may not be the same as the one in the scene.