As the title asks I need a way to use the even-odd rule algorithm and as far as I am aware raycasts in unity only allow one collision per mesh and i need a way to detect whether the player is inside a specific mesh.
Wouldn’t it be better to use OnTriggerEnter/Stay/Exit for this?
would OnTriggerStay work if the object is fully inside the collider and not touching the “skin” of it?
and i would personally like to learn how to implement the algorithim into unity
Yes, OnTriggerStay gets called whenever two triggers intersect, this includes when one is fully inside another.
If you want do do it with raycasts, I think you can just cast a new ray from the hit point (plus a little offset).
You could also do the triangle ray intersection test yourself.
What is the triangle ray intersection test? When i Google it I get examples in code and jargon I cannot understand.
It’s what raycasting does to each triangle in a mesh collider to find out if the ray hits anything.
Here’s an implementation that shouldn’t be hard to translate: