My virtual world is not completely flat. There are inclines and raised areas that the animation models and the player (camera) have to traverse. Therefore, I need to adjust the model or cameras Y
position so that it the object stays above the current height of the floor as it moves about.
Determining this value is actually trickier than it appears, at least to me. I thought about raycasting in the negative Y direction for intersecting objects, but what happens if the model ends up below the floor? I thought about then raycasting in the positive and negative Y
directions and taking the largest Y
value as the floor value across the values found, but then I can’t have any ceilings or upper levels.
Is there a known technique or strategy that isn’t a CPU hog for dealing with the problem of determining the proper Y
value, when moving an animation model or the camera, so that it always is at the right elevation depending on the current height of the floor?