Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- // This is what our events look like
- public delegate void AimTrackerEvent(Vector3 point, int playerNumber);
- public class AimTracker : MonoBehaviour {
- // These are all the events
- public static AimTrackerEvent OnTrackerMove;
- public static AimTrackerEvent OnTrackerClick;
- // Update is called once per frame
- void Update () {
- float hori1 = Input.GetAxis("joystick 1 analog 0");
- float vert1 = Input.GetAxis("joystick 1 analog 1");
- float hori2 = Input.GetAxis("joystick 2 analog 0");
- float vert2 = Input.GetAxis("joystick 2 analog 1");
- // CLEAN
- // If someone is listening
- if (OnTrackerMove!=null){
- // Broadcast our message
- OnTrackerMove(new Vector3(hori1, vert1, 0), 1);
- OnTrackerMove(new Vector3(hori2, vert2, 0), 2);
- }
- }
- }
Add Comment
Please, Sign In to add comment