StillAnimator.cs 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using Sirenix.OdinInspector;
  5. namespace KairoEngine
  6. {
  7. public enum StillPositions
  8. {
  9. Idle1,
  10. Idle2,
  11. IdleRifle1,
  12. IdleRifle2,
  13. IdleCrouched
  14. }
  15. public class StillAnimator : MonoBehaviour
  16. {
  17. public Animator animator;
  18. public StillPositions stillPosition;
  19. private StillPositions previousPosition;
  20. void Start()
  21. {
  22. int position = System.Convert.ToInt32(stillPosition);
  23. //Debug.Log($"{gameObject.name} animator position: {position.ToString()}");
  24. animator.SetInteger("Position", position);
  25. previousPosition = stillPosition;
  26. }
  27. void Update()
  28. {
  29. if(stillPosition != previousPosition)
  30. {
  31. previousPosition = stillPosition;
  32. int position = System.Convert.ToInt32(stillPosition);
  33. animator.SetInteger("Position", position);
  34. //Debug.Log($"{gameObject.name} animator position: {position.ToString()}");
  35. }
  36. }
  37. }
  38. }