So my controller works perfectly on the computer when dragged by a mouse, however, Im getting complaints that when on mobile the controls are buggy and not playable at all.
This is a video of our PC playing the game:
and here is the code I made to find out where the analog stick was… my only solution would be to turn the value into Screen.Width / something but Im somewhere lost as to how I can do this.
[SerializeField]private bl_Joystick Joystick;//Joystick reference for assign in inspector
[SerializeField]public bl_Joystick Joystick2;//Joystick reference for assign in inspector
public Transform camera;
public Animator anim;
public float v;
public float h;
public float h2;
[SerializeField]private float Speed = 5;
void Update()
{
//Step #2
//Change Input.GetAxis (or the input that you using) to Joystick.Vertical or Joystick.Horizontal
v = Joystick.Vertical; //get the vertical value of joystick
h = Joystick.Horizontal;//get the horizontal value of joystick
h2 = Joystick2.Horizontal;//get the horizontal value of joystick
//in case you using keys instead of axis (due keys are bool and not float) you can do this:
//bool isKeyPressed = (Joystick.Horizontal > 0) ? true : false;
//ready!, you not need more.
if (v >= 0.1f && v <= 1.4f) {
anim.SetBool ("walk", true);
anim.SetBool ("walkb", false);
}
if (v >= 1.5f) {
anim.SetBool ("run", true);
}
if (v <= -0.9f) {
anim.SetBool ("walkb", true);
anim.SetBool ("walk", false);
anim.SetBool ("run", false);
}
if (v == 0) {
anim.SetBool ("walk", false);
anim.SetBool ("walkb", false);
anim.SetBool ("run", false);
}
if (h2 >= 0.4f) {
camera.Rotate (0, h2 * Time.deltaTime * 13, 0);
}
if (h2 <= -0.4f) {
camera.Rotate (0, h2 * Time.deltaTime * 13, 0);
}
}