The Ultimate Character Locomotion component can run in the Update or Fixed Update loop. If the character is running within Fixed Update the Kinematic Object Manager ensures the character (and other kinematic objects) move at a smooth rate while updating at a fixed timestep. If you want to have your object moved by the Kinematic Object Manager you can implement the IKinematicObject interface but this isn’t always possible, especially when integrating the controller with other assets. The Move With Object ability will allow your character to move with the target object even if that target object is updated outside of the Kinematic Object Manager loop. The target object must be updated within the Fixed Update loop otherwise there will be noticeable jitter. This does not apply if your character is updating within Update.
- Select the + button in the ability list under the “Abilities” foldout of the Ultimate Character Locomotion component.
- Add the Move With Object ability. The ability will be able to start no matter what position it is in within the ability list.
- Ensure the object that the character should follow updates within the FixedUpdate loop. In the demo scene the SimplePlatform component is an example of a object that can move the character while executing outside of the Kinematic Object Manager loop.
- Add the Kinematic Object component to the object that the character should follow. In the demo this is the same object that the SimplePlatform component was added to.
- Ensure the script that updates within FixedUpdate executes before the Kinematic Object component and after the Kinematic Object Manager. In most cases nothing needs to be changed but if the script updates after the Kinematic Object component then there will be jitter. This can be set in the Script Execution Order window.
- The Move With Object ability will start when it has a Target field, and it will stop when the Target field is set to null. For example, the SimplePlatform component in the demo project sets the Target field of the Move With Object ability when a character enters its trigger collider.
- To do this in code, you need to first get a reference to the Move With Object ability – for this, you can use UltimateCharacterLocomotion.GetAbility (as described under the “API” section on this page), then set the ability’s Target to the transform of the object that the character should move with.
The object that the character should move with.