//Alfred Lai - Custom joystick function float joyStickInput(MPJoystick joystick) { Vector2 absJoyPos = new Vector2(Mathf.Abs(joystick.position.x), Mathf.Abs(joystick.position.y)); float xDirection = (joystick.position.x > 0) ? 1 : -1; float yDirection = (joystick.position.y > 0) ? 1 : -1; return ((absJoyPos.x > absJoyPos.y) ? absJoyPos.x * xDirection : absJoyPos.y * yDirection); }
void Awake() { myAnimator = GetComponent <Animator>(); myTransform = transform; JoyHandle = GameObject.FindGameObjectWithTag("JoyHandle"); moveJoystick = JoyHandle.transform.FindChild("Joy").GetComponent <MPJoystick>(); joyJump = JoyHandle.transform.FindChild("jump"); }
private float tapTimeWindow; // How much time there is left for a tap to occur #endregion Fields #region Methods public static MPJoystick Get() { if (m_Instance == null) m_Instance = (MPJoystick)FindObjectOfType(typeof(MPJoystick)); return m_Instance; }