var space_state = get_parent().get_parent().get_parent().get_world_3d().direct_space_state
1 Like
It’s probably not the best idea to go back 3 generations like that, no. You’d ideally find another way to get that reference, depending on the project’s structure.
Your code fails if there is no 3rd parent or that node isn’t a Node3D.
I’d rather use an exported property and set your node explicitly.
get_viewport().get_world_3d().direct_space_state should be more reliable if the code is inside a node
3 Likes