Guest User

Untitled

a guest
Jul 18th, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. // This is what our events look like
  6. public delegate void AimTrackerEvent(Vector3 point, int playerNumber);
  7.  
  8. public class AimTracker : MonoBehaviour {
  9.  
  10. // These are all the events
  11. public static AimTrackerEvent OnTrackerMove;
  12. public static AimTrackerEvent OnTrackerClick;
  13.  
  14. // Update is called once per frame
  15. void Update () {
  16. float hori1 = Input.GetAxis("joystick 1 analog 0");
  17. float vert1 = Input.GetAxis("joystick 1 analog 1");
  18. float hori2 = Input.GetAxis("joystick 2 analog 0");
  19. float vert2 = Input.GetAxis("joystick 2 analog 1");
  20.  
  21. // CLEAN
  22. // If someone is listening
  23. if (OnTrackerMove!=null){
  24. // Broadcast our message
  25. OnTrackerMove(new Vector3(hori1, vert1, 0), 1);
  26. OnTrackerMove(new Vector3(hori2, vert2, 0), 2);
  27. }
  28. }
  29. }
Add Comment
Please, Sign In to add comment