Move With Object
Move With Object keeps the character at the same relative position and rotation as a selected moving object. Use it when the character must follow an object even when ordinary grounded moving-platform detection should not control the relationship.
Before you begin
- The character must have an Ultimate Character Locomotion component.
- Add the Kinematic Object component to the exact target Transform that will be assigned to the ability. Move With Object rejects a target without this component.
- Set up the target’s movement before connecting it to the character. Kinematic Object registers externally moved objects with the Simulation Manager so their motion can remain synchronized.
For a floor, elevator, or other surface that the character simply stands on, use the normal Moving Platforms workflow. Move With Object is for an explicit target relationship that overrides normal ground-based platform selection.
Add Move With Object
- Select the GameObject that the character should follow.
- In the Inspector, select Add Component and add Kinematic Object to that same GameObject.
- Select the character GameObject.
- In the Ultimate Character Locomotion component, expand Abilities.
- Select the plus button and add Move With Object.
- Keep Enabled selected, Start Type set to Automatic, and Stop Type set to Automatic.
- For a fixed scene relationship, drag the target Transform into Target. For a relationship chosen during gameplay, leave Target empty and assign it at runtime.
Move With Object is concurrent and has no special list-order requirement. It can remain active while the character uses normal locomotion and other compatible abilities.
Choose how to use the target
Follow one known object
Assign a scene object to Target in the Inspector when the character should follow it as soon as the scene begins. Because the ability starts automatically, a valid assigned target activates Move With Object in Play Mode without an input binding.
Attach and detach during gameplay
Leave Target empty when an interaction, animation, or gameplay system decides when the relationship begins. Set the Target property to a Transform with Kinematic Object to attach, then set it to null to detach. The automatic stop waits for the target to become null.
If the character should switch directly between two moving objects, assign the new valid target while the ability is active. The locomotion system immediately records the character’s relationship to the replacement target.
Use an ability-owned relationship
Some detected-object and detected-ground abilities expose their own Move With Object setting. Use that setting when the relationship should exist only for that ability’s lifetime. Use the standalone Move With Object ability when another gameplay system owns the target and attachment timing.
How Move With Object runs
The automatic start check succeeds only while Target is not null. When the ability starts, it calls the character locomotion system’s moving-platform workflow with an override, storing the character’s position and rotation relative to the target.
Each locomotion update adds the target’s movement and rotation changes to the character. The override prevents ordinary ground detection from replacing the selected target, while the concurrent ability allows the character’s own movement and compatible abilities to continue relative to that object.
Setting Target to null allows the automatic stop. Stopping clears the moving-platform override and returns ownership to normal ground detection. The character’s Stick To Moving Platform, Moving Platform Disconnect Movement Multiplier, and Moving Platform Force Damping settings determine how platform motion is handled around separation.
Verify in Play Mode
- Start with a valid Target assigned or assign one through the gameplay system.
- In the Ultimate Character Locomotion Inspector, confirm (Active) appears beside Move With Object.
- Translate the target and confirm the character preserves its relative position.
- Rotate the target and confirm the character follows the expected platform rotation without drifting.
- Move the character while the target is moving and confirm normal locomotion remains available relative to the target.
- Assign a second valid target and confirm the character begins following it without first needing to stop the ability.
- Set Target to
null. Confirm Move With Object becomes inactive and later target movement no longer carries the character.
Troubleshoot Move With Object
- The ability never becomes active: check that Enabled is selected, Start Type is Automatic, and Target is assigned.
- The Console reports that the target does not have Kinematic Object: add Kinematic Object to the exact Transform assigned to Target. A component on a parent or child does not satisfy the target check.
- The character jitters while following the object: confirm the assigned Transform has Kinematic Object and is not being moved by multiple competing systems.
- The character follows only while standing on the object: confirm Move With Object is active. A character that follows only while grounded is using normal moving-platform detection rather than the explicit override.
- The ability stops and immediately starts again: clear Target before force-stopping it. A non-null target continues to satisfy the automatic start condition.
- The wrong object carries the character: check which system last assigned Target or called the locomotion moving-platform API, then give one system ownership of the relationship.
- The character keeps too much or too little motion after detaching: review Stick To Moving Platform, Moving Platform Disconnect Movement Multiplier, and Moving Platform Force Damping on Ultimate Character Locomotion.
Related topics
- Moving Platforms covers automatic ground-based platform movement and platform components.
- Abilities explains automatic start and stop types, concurrent abilities, and runtime activation.
- Detect Object Ability Base includes an ability-owned Move With Object option for detected objects.
- Detect Ground Ability Base includes the equivalent option for a detected ground object.
Developer reference
Retrieve Move With Object from UltimateCharacterLocomotion and assign its Target property. Assigning a Transform without Kinematic Object logs a Console message and resets the target to null.
using UnityEngine;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;
public class MoveWithTarget : MonoBehaviour
{
[SerializeField] private UltimateCharacterLocomotion m_CharacterLocomotion;
[SerializeField] private Transform m_Target;
public void Attach()
{
var moveWithObject = m_CharacterLocomotion.GetAbility<MoveWithObject>();
moveWithObject.Target = m_Target;
}
public void Detach()
{
var moveWithObject = m_CharacterLocomotion.GetAbility<MoveWithObject>();
moveWithObject.Target = null;
}
}
The runtime behavior is intentionally small:
- Target validates the assigned Transform and changes the active moving-platform override when the target changes.
- CanStartAbility requires a non-null target.
- CanStopAbility allows the automatic stop after the target becomes null; a forced stop can occur at any time.
- AbilityStarted calls
SetMovingPlatform(Target, true). - AbilityStopped calls
SetMovingPlatform(null, false). - IsConcurrent returns
true.
Move With Object does not send a feature-specific event. Use the shared ability lifecycle or observe the Target property when another system needs attachment state.