You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

37 regels
713 B

  1. using System;
  2. using UnityEngine;
  3. public class MirrorWalkAnimator : MonoBehaviour
  4. {
  5. private void Start()
  6. {
  7. this.scale = base.transform.localScale.x;
  8. }
  9. private void Update()
  10. {
  11. this.Flip();
  12. }
  13. private void Flip()
  14. {
  15. int integer = this.animator.GetInteger("Direction");
  16. if (integer == this.cachedDirection)
  17. {
  18. return;
  19. }
  20. this.cachedDirection = integer;
  21. bool flag = integer == 0 || integer == 1;
  22. Vector3 localScale = base.transform.localScale;
  23. localScale.x = ((!flag) ? this.scale : (-this.scale));
  24. base.transform.localScale = localScale;
  25. }
  26. [SerializeField]
  27. private Animator animator;
  28. private int cachedDirection = -1;
  29. private float scale;
  30. }