Advertisement
Guest User

new animation

a guest
Jan 22nd, 2020
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. using UnityEngine;
  2. using UnityEngine.AI;
  3.  
  4. public class characterAnimator : MonoBehaviour {
  5.  
  6. const float locamotionSmoothTime = .1f;
  7. public GameObject player;
  8. float agent;
  9. Animator animator;
  10.  
  11. // Start is called before the first frame update
  12. void Start()
  13. {
  14. var agent = player.GetComponent<playerMovementScript>().speed;
  15. animator = GetComponentInChildren<Animator>();
  16.  
  17. }
  18.  
  19. // Update is called once per frame
  20. void Update()
  21. {
  22. float speedPercent = agent / Time.deltaTime;
  23. animator.SetFloat("speedPercent", speedPercent, locamotionSmoothTime, Time.deltaTime);
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement