A way to find the id of an Instanced Mesh with onCollide function? #106
-
Hello! Is there any way of getting the ID of an Instanced Mesh element when it collides with something? I've tried looking into the event, instanceMatrix of the Instanced Mesh, but found no clues on this question. I have a following code, think it should be enough for understanding.
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Okay, finally I got this! The reason is that useCannon sees the collision as an interaction between objects — in our case it is instancedMesh and another object. So, when instancedMesh collides, useCannon sees the whole object and can't distinguish one of the many meshes from another. So the solution was to switch from instancedMesh to an array of meshes and to handle all the logic inside each of them. |
Beta Was this translation helpful? Give feedback.
Okay, finally I got this! The reason is that useCannon sees the collision as an interaction between objects — in our case it is instancedMesh and another object. So, when instancedMesh collides, useCannon sees the whole object and can't distinguish one of the many meshes from another.
So the solution was to switch from instancedMesh to an array of meshes and to handle all the logic inside each of them.