- Edited
Hi, I'm playing around with building a terrain mesh procedurally, and while I like where the the mesh generation is going, I'm a bit stumped on what is the correct way to create a collision shape for the generated mesh at runtime.
If it matters, I'm building a terrain for a strategy game, and mainly trying to detect mouse clicks on the map.
In my head, the ideal solution would be to use a StaticBody3D
, generate the mesh and assign it to a MeshInstance3D
child, generate a collision shape and assign it to a CollisionShape3D
child, and use _input_event
on the static body to detect unhandled input with object picking on. Is this an "idiomatic" approach to this in Godot?
I also tried create_trimesh_collision
on a MeshInstance3D
which also works, but leads to a weird setup where StaticBody3D
is created dynamically and requires a bit of additional wiring at runtime to make the click detection work, either by dynamically connecting to input signals or doing some node navigation on ray-casts to get the actual node I want, both of which don't feel that nice to do. Also, the docs mention that create_trimesh_collision
is mostly used for testing.