Question by 
               TheOneMiner · Sep 19, 2021 at 11:19 AM · 
                animationmovementplayermovement script  
              
 
              ´How to check if 3D player is moving?
I'm trying to animate my player. I have the animations ready and a script for the animation. The Animation float "speedPercent" is just staying the same. Is it possible to see that if the player is stopped or moving in the CharacterController script? I tried to follow this video.
CharacterController.cs
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine.EventSystems;
 using UnityEngine;
 using UnityEngine.AI;
 
 public class CharacterController : MonoBehaviour
 {
     public float Speed;
     NavMeshAgent agent;
     public bool isSpeed;
 
 
     void Start()
     {
 
         agent = GetComponent<NavMeshAgent>();
         Speed = agent.speed;
         Cursor.visible = false;
         Cursor.lockState = CursorLockMode.Locked;
     }
  
     // Update is called once per frame
     void Update()
     {
     
         if (EventSystem.current.IsPointerOverGameObject())
             return;
 
         PlayerMovement();
     }
 
     void PlayerMovement()
     {
         float hor = Input.GetAxis("Horizontal");
         float ver = Input.GetAxis("Vertical");
         Vector3 playerMovement = new Vector3(hor, 0f, ver) * Speed * Time.deltaTime;
         transform.Translate(playerMovement, Space.Self);
     }
 }
Animation.cs
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.AI;
 
 public class Animation : MonoBehaviour
 {
     const float locomationAnimationSmoothTime = .2f;
     
     NavMeshAgent agent;
     Animator animator;
 
     // Start is called before the first frame update
     void Start()
     {
         agent = GetComponent<NavMeshAgent>();
         animator = GetComponentInChildren<Animator>();
     }
 
     // Update is called once per frame
     void Update()
     {
         float speedPercent = agent.velocity.magnitude / agent.speed;
         animator.SetFloat("speedPercent", speedPercent, locomationAnimationSmoothTime, Time.deltaTime);
     }
 }
 
I'm trying to follow this video:
               Comment
              
 
               
              Your answer
 
 
             Follow this Question
Related Questions
How to move 3 players at the same time in V form,How to move 3 characters in the same time in V form 0 Answers
Dash Movement Platformer 0 Answers
Object rotates when moving sideways 0 Answers
How do I make my player jump? 1 Answer
Player only moves when the key is pressed, not when it's held. 0 Answers
 koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                