Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using UnityEngine.AI;
- public class characterAnimator : MonoBehaviour {
- const float locamotionSmoothTime = .1f;
- public GameObject player;
- float agent;
- Animator animator;
- // Start is called before the first frame update
- void Start()
- {
- var agent = player.GetComponent<playerMovementScript>().speed;
- animator = GetComponentInChildren<Animator>();
- }
- // Update is called once per frame
- void Update()
- {
- float speedPercent = agent / Time.deltaTime;
- animator.SetFloat("speedPercent", speedPercent, locamotionSmoothTime, Time.deltaTime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement