Advertisement
MaoChessy

Untitled

Feb 8th, 2022
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.31 KB | None | 0 0
  1. using System;
  2. using Animancer;
  3. using DIContainer;
  4. using UltEvents;
  5. using UnityEngine;
  6.  
  7. namespace DefaultNamespace.AnimScripts
  8. {
  9. public class AnimMainCharacter : MonoBehaviour
  10. {
  11. public AnimancerComponent AnimancerComponent;
  12. public ClipTransition Idel;
  13. public ClipTransition Walk;
  14. public ClipTransition Jump;
  15. public ClipTransition Fall;
  16.  
  17. [SerializeField] private MonoInput _monoInput;
  18. [SerializeField] private GroundCheck _groundCheck;
  19.  
  20. public UltEvent PositiveMove;
  21. public UltEvent NegativeMove;
  22.  
  23. private void OnEnable()
  24. {
  25. _monoInput.OnMove += OmMove;
  26. _monoInput.StartJump += OnJump;
  27. _monoInput.FinishJump += OnFinishJump;
  28. }
  29.  
  30. private void OnFinishJump() => AnimancerComponent.Play(Fall);
  31.  
  32. private void OnJump() => AnimancerComponent.Play(Jump);
  33.  
  34. private void OmMove(Vector2 obj)
  35. {
  36. if(obj.x>0) PositiveMove.Invoke();
  37. else if(obj.x<0) NegativeMove.Invoke();
  38. if(_monoInput.IsJump)
  39. return;
  40. if(_groundCheck.IsGround==false) OnFinishJump();
  41. else if (obj.x != 0) AnimancerComponent.Play(Walk);
  42. else AnimancerComponent.Play(Idel);
  43. }
  44. }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement