RayCast not working with MeshCollider - Unity's roller ball collision works
Hello, there.
I'm doing a small experiment with terrain generation and avatar control. I'm using a mesh for the terrain. It works fine, and the mesh collider works with Unity's roller ball (collision detection is fine, there, the ball rolls over the terrain, etc.).
When trying to make my own controller, however, it does not works. I'm using simple 2D movement, projected onto the mesh (it's surjective). My idea, then, is to use a vertical Raycast to find where the character should go. But I get no collision at all!
I've tried using a simple, default, cube and the Raycast works with it. It just doesn't work with the MeshCollider, for some reason.
Any ideas? I can post code or more information if needed.
Thanks!
Answer by maxmet · Apr 12, 2018 at 03:19 PM
As one is wont to do, I found the solution immediately after posting this.
Apparently, Mesh Colliders use backface culling. I was hitting them from below, so it didn't work. Hitting them from above works. Hope it helps someone.