Search Unity

Help Wanted Use playable set human root poisition

Discussion in 'Animation' started by Black_Spree, Aug 15, 2021.

  1. Black_Spree

    Black_Spree

    Joined:
    Dec 11, 2019
    Posts:
    1
    Hi, I try to use AnimatorControllerPlayable set human animator(Apply Root Motion is true) root position, but it dose't work.
    This is my code, is possible?
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Animations;
    3.  
    4. public struct KeepFoot : IAnimationJob
    5. {
    6.     public TransformStreamHandle foot;
    7.     public TransformStreamHandle root;
    8.  
    9.     private Vector3 footPos;
    10.     public void ProcessAnimation(AnimationStream stream)
    11.     {
    12.         stream.velocity = Vector3.zero;
    13.         var buf = stream.AsHuman();
    14.         buf.bodyLocalPosition = Vector3.zero;
    15.         buf.bodyRotation = Quaternion.identity;
    16.         root.SetRotation(stream, Quaternion.identity);
    17.  
    18.     }
    19.  
    20.     public void ProcessRootMotion(AnimationStream stream)
    21.     {
    22.         stream.velocity = Vector3.zero;
    23.         var buf = stream.AsHuman();
    24.         buf.bodyLocalPosition = Vector3.zero;
    25.         buf.bodyRotation = Quaternion.identity;
    26.         root.SetRotation(stream, Quaternion.identity);
    27.     }
    28. }
    29.  
     
unityunity