Is there any way of checking if a ray is colliding with the internal edge of a collider? It doesn’t seem to be working…
I am using this to check if a point resides inside a mesh by casting a ray from outside the mesh toward the point and counting the times it intersects the mesh. Unfortunately it doesn’t seem possible to get the internal collision on the collider edge… There’s got to be a way though. any suggestions?
Hmmm… if all you wanted to do was check if a point was inside a mesh collider, why not make the collider a trigger, and put some code on the point, and use OnTriggerStay()?
Hmmm. That makes sense.I don’t know if your solution applies to my particular case which I should have explained in greater depth…
Essentially I am building a voxelated version of a mesh so that I can apply realistic buoyancy to it. Imagine the hull of a boat, voxelated, so that I can apply the right amount of buoyant force to the different parts of the ship.The raycast solution was to tell which voxels should be “lit”. I don’t really need to check if a point resides inside a mesh during gameplay
Sorry for the confusing explanation.
I think I may have found a workaround which uses 6 raycasts, from the 6 different directions, toward the point. If all raycasts collide with the mesh, the point can said to be inside the mesh (not technically true for hollow or very concave shapes.)
Your solution might be workable too, and probably wouldn’t suffer from the inaccuracies with concave shapes… but then again I don’t know if the trigger would work right on a concave mesh anyways.