Question by
ElectronicFranks · Jul 22, 2019 at 08:55 AM ·
c#androidjoysticktouchscreen
Using the free touchscreen Joystick my code cant detect the joystick
public Joystick joystick;
float speed2 = 100.0f;
float speed1 = -100.0f;
public float speed;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void FixedUpdate()
{
if (Input.GetKey("d")) transform.Rotate(new Vector3(0f, 0f, 1f) * (speed1 * joystick.horizontal) * Time.deltaTime);
if (Input.GetKey("a")) transform.Rotate(new Vector3(0f, 0f, 1f) * speed2 * Time.deltaTime);
if (Input.GetKey("w")) transform.Rotate(new Vector3(1f, 0f, 0f) * speed2 * Time.deltaTime);
if (Input.GetKey("s")) transform.Rotate(new Vector3(1f, 0f, 0f) * speed1 * Time.deltaTime);
transform.position += transform.forward * Time.deltaTime * speed;
}
Nevermind the last part, I know it needs fixing, the problem is "public Joystick joystick", it wont work, and in unity it wont appear, like the other public float. How can I fix this?
Comment
Your answer
Follow this Question
Related Questions
How can i make my player look at the same direction where its moving? [JOYSTICK ANDROID] 0 Answers
Unity2d-Android-C#: How to convert current movement script to be used for touchscreen? 1 Answer
Unity 2d android game How to "freeze" position on Y axis 1 Answer