Jumping without root animation

This is most likely a stupid question but I tend to overthink things since I’m new to Unity and gamedev.

I’m controlling a characters movement using the CharacterController and all of my characters walk/run etc animations are “inplace” (no root motion). So when I press forward I just translate his position forward. Basic stuff.

If I now want to have a forward roll/forward jump/vault over or any animation that would move your character through space, does that mean that I now I have to move the characters position by script as-well for those things adjusting his movement speed etc?

E.g. If I wanted to jump forward while running, would I have to trigger the “inplace” jump animation and then increase his forward position by a set amount to move him? That seems messy and inaccurate.

I’d be grateful for any resources. I’ve been looking but most of the stuff is really basic.

With a CharacterController all your movement is scripted (except for root motion). If you want to fall according to gravity, you need to have a vertical velocity which you accelerate downwards then use that to update your position every frame (when you aren’t grounded). So to jump you just go the other way. The 3D Game Kit uses root motion for most movement but the jumping is entirely scripted. The documentation of my Animancer plugin has an example which breaks down the individual parts of that character in order to explain how you could implement the same thing with Animancer instead of an Animator Controller, so you might find that useful as well.

I’ve seen videos on how to apply gravity to a character controller. My question is more about how to do a forward jump without root motion. Again forward jump is just an example. It could apply to any animation that would move your character in 3d space if root motion was applied.

So for a forward jump, would I just modify the position of the character when pressing a button that triggers the jump forward animation?

Whats the best way to know by how much to move a character whether they’re walking or jumping etc if using inplace animations to avoiding sliding?

I’m not really sure what you’re asking. Most games don’t do anything special for a moving jump, they just let you keep moving horizontally at your regular speed with less acceleration so you can’t change direction as quickly. A vertical jump moves the character every frame according to its velocity and a forward jump would be no different, it’s just a movement in a particular direction.

You could track the position of the feet and apply that as movement every frame to avoid sliding.

I think you answered my question in regards to the jumping. If I’m not using root motion i’ll always have to translate the position of the character through script, regardless of what motion he’s doing. I was hoping maybe there was a way of using both. So for more dynamic moves I could use root motion.

You said I could track the position of the feet and apply that as movement. Do you have any examples?

You can enable and disable root motion whenever you want or implement an OnAnimatorMove method so that you get to read root motion from the animations and decide what you want to do with it every frame like the 3D Game Kit does. But yes, the only two things that move a CharacterController are root motion and your own scripts.

Tracking the position of the feet should be easy. Just get a reference to the bone and store its position every update, then you can calculate movementSinceLastFrame = footBone.position - previousPosition. I’m not sure what the best way would be to decide which foot to use at any given time though. Maybe a Custom Animation Curve which goes from 0 (left foot) to 1 (right foot) and back.