/// <summary>
        /// Fires when the graph for the timeline begins playing.
        /// </summary>
        public override void OnGraphStart(Playable playable)
        {
            stateDrivers = new Dictionary <Type, StateDriver>();

            PlayerCharacter player = GameManager.Player != null ? GameManager.Player : GameObject.FindObjectOfType <PlayerCharacter>(true);

            if (player == null)
            {
                return;
            }

            // Keep the player from changing animation/behavior states.
            player.FSM.Pause();

            // Take a snapshot of where the player started for the sake of potentially
            // restoring them later.
            GraphSnapshot = new PlayerSnapshot(player);

            // During mixing, the virtual snapshot is updated as needed by absolute posing and referenced by
            // relative posing.
            VirtualSnapshot = GraphSnapshot;

            Rigidbody2D rb = player.GetComponentInChildren <Rigidbody2D>(true);

            if (rb != null)
            {
                rb.gravityScale = 0;
                rb.velocity     = Vector3.zero;
            }
        }
        /// <summary>
        /// Apply the pose of an absolute clip.
        /// </summary>
        /// <param name="player">The player character</param>
        /// <param name="pose">The pose to apply</param>
        /// <param name="weight">(optional) The weighting on the pose, used to
        /// interpolate this pose with another if necessary. Default: 1.</param>
        /// <param name="updateVirtualSnapshot">(optional) Whether or not to update the mixer's virtual snapshot
        /// of the player character. When mixing multiple absolute poses, this
        /// action can be saved for the last pose applied. Default: true.</param>
        private void MixAbsolute(PlayerCharacter player, AbsolutePoseInfo pose, float weight = 1f, bool updateVirtualSnapshot = true)
        {
            PoseTools.MixAbsolute(player, VirtualSnapshot, pose, weight);

            if (updateVirtualSnapshot)
            {
                VirtualSnapshot = new PlayerSnapshot(player);
            }
        }
Пример #3
0
        /// <summary>
        /// Apply the pose of an absolute clip.
        /// </summary>
        /// <param name="player">The player character</param>
        /// <param name="snapshot">A snapshot of player character information. This
        /// gets mixed into the player's pose as well.</param>
        /// <param name="pose">The pose to apply</param>
        /// <param name="weight">(optional) The weighting on the pose, used to
        /// interpolate this pose with another if necessary. Default: 1.</param>
        /// <param name="updateVirtualSnapshot">(optional) Whether or not to update the mixer's virtual snapshot
        /// of the player character. When mixing multiple absolute poses, this
        /// action can be saved for the last pose applied. Default: true.</param>
        public static void MixAbsolute(PlayerCharacter player, PlayerSnapshot snapshot, AbsolutePoseInfo pose, float weight = 1f)
        {
            Vector3 pos = snapshot.Position;
            Vector3 rot = snapshot.Rotation;
            Vector3 scl = snapshot.Scale;

            player.transform.position    = (pose.Position - pos) * weight + pos;
            player.transform.eulerAngles = (pose.Rotation - rot) * weight + rot;
            player.transform.localScale  = (pose.Scale - scl) * weight + scl;
        }
Пример #4
0
 /// <summary>
 /// Apply the pose of a relative clip.
 /// </summary>
 /// <param name="player">The player character</param>
 /// <param name="snapshot">A snapshot of player character information. This
 /// gets mixed into the player's pose as well.</param>
 /// <param name="pose">The pose to apply</param>
 /// <param name="weight">(optional) The weighting on the pose, used to
 /// interpolate this pose with another if necessary. Default: 1.</param>
 public static void MixRelative(PlayerCharacter player, PlayerSnapshot snapshot, RelativePoseInfo pose, float weight = 1f)
 {
     player.transform.position    += pose.Position * weight;
     player.transform.eulerAngles += pose.Rotation * weight;
     player.transform.localScale   = (pose.Scale - snapshot.Scale) * weight + snapshot.Scale;
 }