Get node from RID or ColliderID

Godot Version

v4.2.1.stable.official [b09f793f5]

Question

I’m working on an inventory system based off System shock’s/Ultima underworld where you can drag objects from the 3D world to your inventory. Currently i’m using Ray-casting to cast a ray from the projected mouse position to the world.

The ray-cast retrieves a dictionary containing the collider id and the RID, How do i get the collider’s path from this?

I need the object’s path so i can delete the node from the tree once it’s been storaged and to get the sprite

snippet:
Inventory function

func _inventory():
# Project mouse position to the world
cursor3D = camera.project_ray_normal(get_viewport().get_mouse_position()) * 7
var space_state = get_world_3d().direct_space_state
var query = PhysicsRayQueryParameters3D.create(camera.global_position, cursor3D + camera.global_position)
var result = space_state.intersect_ray(query)

if result != null and result.collider is RigidBody3D:
	pass

Look in query. It’s a dict with stuff you can use.

Try: collider (The colliding object.)
So

if "collider" in query:
  var pth = query.collider.get_path()
  print(pth)

Prob check that collider is a Node3D or summin first.

Also collider_id and rid in case collider is no good.