Unity Standard Assets Joystick script doesn't work
Hello everyone,
I'm having a problem with the Joystick script from Unity's standard assets. I have an assignment for university in which we have to make a mobile game, so naturally I'd like an on-screen joystick.
I'm using Unity 2019.1.61f (Required for the coursework and part of my project brief), and Standard Assets 2018.4 (The only version I can find in the asset store - if there's a 2019 version I'm happy to get a link!)
I've created a brand new project, imported the CrossPlatformInput package, and created a Joystick from a canvas image. I attached the Joystick script, and left it entirely default. Next, I created an empty game object, and added debug lines into an Update method:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityStandardAssets.CrossPlatformInput;
public class TestJoystick : MonoBehaviour
{
void Update()
{
float hori = CrossPlatformInputManager.GetAxis("Horizontal");
float vert = CrossPlatformInputManager.GetAxis("Vertical");
Debug.Log("Horiztonal: " + hori + ", Vertical: " + vert);
}
}
I believe this is about as simple as I can make anything in order to rule out any other problems. However, when I run the game, moving the joystick just prints 0,0 as my debug. Using WASD or arrow keys prints values moving towards 1/-1 as expected, so this is a problem with the joystick itself.
One additional note, I also tried the mobile joystick prefab, but the assets are disabled and it wont let me enable them, and so I can't use that to even debug the joystick script or make sure the joystick functionality works.
Has anyone got any idea why this might be happening?
Your answer
Follow this Question
Related Questions
Make CrossPlatformInput Joystick scale with resolution 1 Answer
Joystick input recognized multiple times 0 Answers
How to fix input button is not setup 0 Answers
Joystick Input from Switch Pro Controller 0 Answers
Joystick 3rd Axis problem on Linux 0 Answers