Advertisement
Guest User

AnimalWagonAligner

a guest
Jul 31st, 2020
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. using System;
  2.  
  3. using MalbersAnimations;
  4. using MalbersAnimations.Controller;
  5. using MalbersAnimations.HAP;
  6. using MalbersAnimations.Utilities;
  7.  
  8. using UniRx;
  9.  
  10. using UnityEngine;
  11.  
  12. [RequireComponent(typeof(WagonController))]
  13. public class AnimalWagonAligner : MonoBehaviour
  14. {
  15. private WagonController _wagon;
  16. [SerializeField] private MWayPoint _forwardPoint = default;
  17. private Zone _zone;
  18.  
  19. private void Awake()
  20. {
  21. _wagon = GetComponent<WagonController>();
  22. _zone = GetComponentInChildren<Zone>();
  23.  
  24. _zone.OnZoneActivation.AsObservable().Subscribe(Mount);
  25. }
  26.  
  27. private void Mount(MAnimal animal)
  28. {
  29. Debug.Log("Mount");
  30. Debug.Log($"animal : {animal}");
  31.  
  32. var userInput = animal.GetComponentInParent<MalbersInput>();
  33. Debug.Log($"userInput : {userInput}");
  34. if (userInput) userInput.enabled = false;
  35.  
  36. animal.CurrentSpeedIndex = 1; // Walk
  37.  
  38. var ai = animal.GetComponent<MAnimalAIControl>();
  39. ai.enabled = true;
  40.  
  41. ai.SetTarget(_forwardPoint.transform, true);
  42. }
  43. public void Disamount()
  44. {
  45.  
  46. }
  47. }
  48.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement