Locomotion

Here's the basics

InputProvider collects inputs and sanitizes them. Player takes ownership of those inputs. Player Avatar has classes like Locomotion which read the inputs inside the owning Player and applies movement translation to the Avatar Object.

Default implementation uses the built in CharacterController. You can override this and implement your own character controller or a third party one. As long as the inputs are passed to it and it considers the few extra functions that Locomotion has then it will work fine.

If you press an action which causes the Animator to enter a state that needs Root Motion - such as a Jumping Attack Slam or something - then you can add a StateBehavior which will tell the locomotion system to definitely include the root motion data in the motion while the Animator is in that state.

There's several State Behaviors you can use to do various things. For instance while doing that Jump Attack you don't want the character moving in weird directions or turning, or using abilities, right? Just add AnimStateDenial and specify you want those things disabled while in this Animation State. The script will make sure the Locomotion is informed of the restriction.

Isn't there an easier way?

While InputProvider is responsible for reading and translating the input data, the AgentLocomotion component reads and acts on the data and assumes it's always good-to-go.

Why do this? Because this effectively reads as "Inputs are decoupled from character behavior". If you switch to a Gamepad,AgentLocomotion does not care. It knows that it's going to get ABC, XYZ and doesn't care what happens to get that data. You want a HOTAS setup for your MOBA? Whatever, that problem only exists for InputProvider and does not propagate.

On the other hand, you are entirely capable of throwing that guarantee out the window and providing a power combo of your own InputProvider and AgentLocomotion if you want to - they could make their own secret rules and dance on the ceiling together if that's what you want. Just keep in mind that other systems read the 'safe' data on AgentLocomotion too and have some expectations of what it should be, so sticking to the built-in design format is the ideal path forward if you want to pull updates in the future instead of hacking your own stuff together everywhere that touches it in source.

Work is in progress for this page.

Last updated