Advice on Unity Timeline keyframing position and rotation

hazuki

Member
Hi,

I'm looking to find the best way to use unity's timeline animation to move and animate UCC controlled characters for use in cutscenes, for the types of animations I require I can't rely on the controller's locomotion to handle the movement/rotation, the motions are far too elaborate and acrobatic and must be controlled by animations and position keyframes. At the moment I have dummy copies of the characters that are swapped in when needed for a cutscene but this is becoming inefficient and it is difficult to keep continuity when they are affected by context (visible damage, rain, custom clothes, hair etc.).

Is there a way to temporarily allow control of the character model to be relinquished from UCC?

Thank you!
 
Actually, I have a potential solution but I have run into one problem. When I want to use the unity timeline for a cutscene including a UCC controlled character I'm not doing this:

- Make a cube or something simple to act as a parent object.
- Animate the cube's position and rotation as if you were animating your character (put a dummy model in there if it helps you visually)
- Add a 'Move With Object' ability to your character
- When you want your timeline cutscene to play at run time use the UCC 'set position and rotation' to teleport the player to the cube...
-... then start the Move With Object ability

The problem I'm experiencing is that using playmaker I can't stop the Move with Object ability, I have the start and stop type both set to manual but the playmaker action always fires the fail event.

Am I doing way too much work for something simple and any idea why the ability won't finish??
 
When you want to go into cinematic mode you can execute the OnEnableGameplayInput event which will prevent the character from being controlled by the player. Do you want any animations to play during the cutscene? If so you'll need to create a new ability which sets the InputVector/DeltaYawRotation of the character to move to the destination (similar to how Move Towards ability works).

The Move with Object ability will stop automatically when there is no Target transform specified.
 
Ah cool, thanks for the quick reply, could I trouble you for a Playmaker action for setting/removing the target transform?
 
Here's a task that will set the target. I'll also include it in the next integration update.

Code:
using UnityEngine;
using Opsive.UltimateCharacterController.Character;
using Opsive.UltimateCharacterController.Character.Abilities;
using Opsive.UltimateCharacterController.Utility;
using HutongGames.PlayMaker;
using Tooltip = HutongGames.PlayMaker.TooltipAttribute;

namespace Opsive.UltimateCharacterController.Integrations.Playmaker
{
    [Tooltip("Sets the Target variable of the Move With Object ability.")]
    [ActionCategory("Ultimate Character Controller")]
    public class SetMoveWithObjectTarget : FsmStateAction
    {
        [Tooltip("A reference to the character. If null it will be retrieved from the current GameObject.")]
        public FsmOwnerDefault m_TargetGameObject;
        [Tooltip("The target to set.")]
        public FsmGameObject m_Target;

        private GameObject m_PrevTarget;
        private UltimateCharacterLocomotion m_CharacterLocomotion;
        private MoveWithObject m_MoveWithObject;

        /// <summary>
        /// Retrieves the specified ability.
        /// </summary>
        public override void OnEnter()
        {
            var target = Fsm.GetOwnerDefaultTarget(m_TargetGameObject);
            if (target != m_PrevTarget) {
                m_CharacterLocomotion = target.GetCachedComponent<UltimateCharacterLocomotion>();
                // Find the specified ability.
                m_MoveWithObject = m_CharacterLocomotion.GetAbility<MoveWithObject>();
                m_PrevTarget = target;
            }

            if (m_MoveWithObject == null) {
                return;
            }

            m_MoveWithObject.Target = m_Target.Value != null ? m_Target.Value.transform : null;

            Finish();
        }

        /// <summary>
        /// Resets the objects back to their default values.
        /// </summary>
        public override void Reset()
        {
            m_TargetGameObject = null;
            m_Target = null;
        }
    }
}
 
Last edited:
Thanks Justin, just gave this a go and a small issue is that, unless I've made a mistake, I can set the UCC character the PM Action relates to but can't actually set the move object target (see image). Currently this allows me to 'unset' the move target object but I can't set one.1417
 
Oops, if you remove [HideInInspector] on this line then it'll appear:

Code:
[HideInInspector] public FsmGameObject m_Target;

I've also edited my post.
 
Top