Wasn’t sure if this should go here or in the scripting thread…
I was thinking, how would you go about driving your character’s movement based on it’s animation. When doing things like walk cycles it’s sufficient to have the character move at a constant pace while playing the animation, but this wouldn’t be as realistic for things like climbing.
When I’m climbing up a wall, my veritical movement is not constant but rather comes in spurts when I pull myself up. How could you get this effect within unity? I was thinking if you set the velocity at certain times using events or directly link the current frame of an animation to a speed variable?
You’ll get that automatically if the animation includes root motion (as most do nowadays) and you check “Apply Root Motion” in the animation import settings.
See the Locomotion Starter demo from Unity (free in the Asset Store) for an example that handles all motion this way, including walking, running, and turning. It doesn’t demonstrate climbing, but that would be the same.
Just to pile on, as long as you make sure your root node animation (call it root, call it character locator, whatever nomenclature you want to use) exists at a position that makes sense visually, having it not be linear speed-wise (like you mentioned, for climbing, or for a stumble for instance) should work fine. The biggest issue from an art/visual point of view is to make sure the character doesn’t move too far off of that point of reference; if he does and the animation gets interrupted for any reason, the resulting “jump” to the root’s position may look bad or unintended.