Search Unity

Animation transition teleports character

Discussion in 'Animation' started by Sclur, Apr 14, 2021.

  1. Sclur

    Sclur

    Joined:
    Nov 22, 2019
    Posts:
    1
    So as the title says, i have an issue, where an animated character makes sudden, and seemingly random "jumps" from position A to B when transitioning from one animation to another. On the following video you can see me pressing the same key, to move the character to a certain direction, and it happens with each key press. Im only using a Player Input to set the Animator parameters, but it happens if i set them by hand too. Using root motion, and the rotation is baked. I have simply no idea what i should look into, so i would be grateful for any advice...


    Code for controls:
    Code (CSharp):
    1.     Vector2 moveDirection;
    2.     Animator animator;
    3.     public void OnMove(InputAction.CallbackContext callbackContext)
    4.     {
    5.         moveDirection = callbackContext.ReadValue<Vector2>();
    6.        
    7.     }
    8.  
    9.     public void Move()
    10.     {
    11.         animator.SetFloat("Forward_Backward", Convert.ToInt32(moveDirection.y));
    12.         animator.SetFloat("Left_Right", Convert.ToInt32(moveDirection.x));
    13.     }
    14.  
    15.     // Start is called before the first frame update
    16.     void Start()
    17.     {
    18.         animator = GetComponent<Animator>();
    19.     }
    20.  
    21.     // Update is called once per frame
    22.     void Update()
    23.     {
    24.         Move();
    25.     }