- Home /
Moving on the uneven terrain with raycasting
I want to make a character move around in hilly terrain. How should I handle movement on an uneven terrain like this?
One of the problems I'd like to avoid it, when going downhill, if all I do is apply a force forward, I will fly in the air for a bit then fall due to gravity, fly again then fall again, and so on.
One way to fix this would be to apply the force tangential to the terrain. However, for this I need to do some raycasts and vector rotations. Would this be a bad (expensive) solution? What other ways are there of moving along an uneven terrain?
Answer by ragnaros100 · Jul 05, 2012 at 02:07 PM
You can make your character check the angle of the ground under him. If the angle is too steem. You simply cannot walk. Then you ofcourse need a way to get him down to flat terrain again (you can do that with some force adjustments)... :)
Hope this helps.