How to make a character step around terrain in a dynamic manner

For example: say I have a river with stepping stones across it, and I want a character that animates to step only on the stones. More examples: if there’s a narrow path, the character will keep their steps close together; or if there’s rocks or a steep part of terrain in the character’s path, they will step around it.
I’ve thought about making a bunch of different stepping direction animations and then somehow probing the ground in front of the character and then blending the animations so the motions line up. I just don’t know how to go about sensing the ground like that without using a million traces and I don’t know if there’s an easier way around setting up the dynamic animations.

I think most big studio games cheat at this and make it simpler by defining boundary zones where the character should choose a certain subset of animations to use and then arranging the terrain to work well with those animations, and synching the animations to the terrain.

I don’t know the most good-looking way to do it.

I just had an idea though: What if instead of tracing from the character or his feet, you trace from the stepping stones once the character enters an overlap/trigger volume around each stone, and then the results of the trace can be passed to the character that the trace hits? Then the feet can be guided between the character’s center of gravity to the stepping stone, and the stone that has the dot product closest to 1.0 between the character’s direction of velocity and the LookAt from the character to the stone, will get preference.

If the trace does not hit the character then there is something in the way of the character stepping to the stone anyway (unless they could step OVER the obstacle I suppose… but you could do another trace from the stone, with a Z offset equal to the character’s half height to find that out)

Not sure if that will work. The idea just came to mind. I haven’t done any dynamic animation yet, just using static mesh hover tanks in my project :slight_smile:

You can think of my idea as sort of little invisible tentacles trying to pull the character’s feet onto the stone he is most moving toward, if it’s within the stone’s overlap radius which should be close to the size of the character’s height or half height.