Thanks, I am trying to do this in the script in runtime without adding objects because this is going to be procedural so i cant constantly add collisions shapes or signals in the editor.
I am interested in the Ray solution. Do you mind expanding on it?
I already have this , but I cant find if cursor3d is in a bbox of a mesh instance or not. I think the ray against this plane is doing a disservice to me, and I need to do this against the actual mesh instances and I do not know how to do it.
var cursorPlane = Plane(Vector3(0,1,0),-10.0)
cursor3D = cursorPlane.intersects_ray(camera3D.project_ray_origin(get_viewport().get_mouse_position()),
camera3D.project_ray_normal(get_viewport().get_mouse_position())
You can also make the static body and the collision when you make the mesh. Rays also require the collision shape to detect any hits.
Another approach is more low-level. Start here:
Youâd make an AABB âaroundâ your cursor and then use RenderingServer class to find intersection. The problem is that your cursor is not actually in the screen, so Iâm not sure how youâll handle z depth.
Do be sure to choose the right class. If you are writing a tool (in-editor) you use different class to a game (that runs). I link to both in my post.
The underlying system if what all collision uses in Godot, so the âServerâ classes are the fastest you can get short of doing it all yourself in C++.