AnimateModel.cs 847 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.Events;
  5. using System;
  6. public class AnimateModel : MonoBehaviour
  7. {
  8. [SerializeField]
  9. private Animation modelBaseAnimation;
  10. [SerializeField]
  11. private UnityEvent walkingFinished;
  12. private bool isWalking = false;
  13. public void PlayModelAnim()
  14. {
  15. modelBaseAnimation.Stop();
  16. modelBaseAnimation.Play("Armature|RunWay03");
  17. isWalking = true;
  18. }
  19. public void StopAnimModel()
  20. {
  21. modelBaseAnimation.Stop();
  22. }
  23. private void Update()
  24. {
  25. if (modelBaseAnimation.isPlaying == false && isWalking)
  26. {
  27. isWalking = false;
  28. walkingFinished.Invoke();
  29. }
  30. }
  31. public void SetWalking(bool walking)
  32. {
  33. isWalking = walking;
  34. }
  35. }