At the moment I'm trying to switch from height-mapped terrain to a model terrain that could be loaded from a file. I'm currently using height-map lookup table to get the height of the terrain at a specific position as a way for the character controller to be able to walk on the terrain, however I'd like to switch to a ray cast method. The current code goes like this>
Create a ray from player position and point it in down direction.
Iterate over every triangle and test if the ray is intersection
Get the height of the triangle at that position
The issue is that I have 30,000 triangles in the mesh. I was wondering if there is anything I can do to speed it up, or how is such a system usually implemented (I mean walkable terrain) maybe I shouldn't even be using raycasting? Thanksl.