PlayerAnimationController.cs 548 B

12345678910111213141516171819202122232425262728293031
  1. using UnityEngine;
  2. public class PlayerAnimationController : MonoBehaviour
  3. {
  4. private Animator animator;
  5. private void Awake()
  6. {
  7. animator = GetComponent<Animator>();
  8. }
  9. public void SetAnimationState(string state)
  10. {
  11. animator.Play(state);
  12. }
  13. public void UpdateAnimation(float speed)
  14. {
  15. animator.SetFloat("Speed", speed);
  16. }
  17. public void TriggerJump()
  18. {
  19. animator.SetTrigger("Jump");
  20. }
  21. public void TriggerAttack()
  22. {
  23. animator.SetTrigger("Attack");
  24. }
  25. }