Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Movements don't work the way it should

Discussion in 'Scripting' started by lucutes, Jun 8, 2020.

  1. lucutes

    lucutes

    Joined:
    May 27, 2020
    Posts:
    12
    I'm trying to make some basic animation, but I ran into this problem. Whenever I move with WASD, it teleports instead of doing the walking animation. Also the idle plays only one time, then it stops: https://i.imgur.com/zZY6w7J.gifv

    My animator setup and the console:

    The code:

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class AppleInput : MonoBehaviour
    6. {
    7. private Animator animator;
    8. // Start is called before the first frame update
    9. void Start()
    10. {
    11.     animator = GetComponentInChildren<Animator>();
    12. }
    13.  
    14. // Update is called once per frame
    15. void Update()
    16. {
    17.     animator.SetFloat("Horizontal", Input.GetAxis("Horizontal"));
    18.     animator.SetFloat("Vertical", Input.GetAxis("Vertical"));
    19. }
    20. }
    Update:

    Forgot to mention, that my character can't move further away, when I release the W key for forward, it comes back to its original place just like in gif.
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,971
    I haven't tinkered with BlendTrees specifically but I don't see you physically moving the object, just setting the animator properties.

    I think for it to move you have to put in some kind of "root motion" option?? I forget exactly because I always move the object myself and sync the animation so I can have precise gameplay even if an animation is messy.
     
    lucutes likes this.
  3. lucutes

    lucutes

    Joined:
    May 27, 2020
    Posts:
    12
    I have the root motion applied in the animator, I tried unticking it, but I got the same results. I could try your way, but since I'm relatively new to Unity, I have no idea how to start.