Question

I'm using Unity, and am trying to use the Joystick namespace. but whenever I try to declare a joystic it says the namespace isn't valid.

Here are the libraries I am using:

    using UnityEngine;
    using System.Collections;
    using Riverscout;

And this is the code that gives me the error:

    public Joystick moveJoystick;

Can anyone tell me what library I need to use to make this work? Thanks in advance.

Was it helpful?

Solution

The UnityEngine namespace doesn't contain any class named Joystick.

You can, however, access joystick input that has been set up in the Input Manager by querying Input.GetAxis().

Suppose you set up a joystick to control two axes, named "Joy0x" and "Joy0y", you could then get the input like so:

function Update() {
    var x = Input.GetAxis("Joy0x");
    var y = Input.GetAxis("Joy0y");
    transform.Rotate(x, y, 0); //rotate attached GameObject
}

I imagine many people have posted joystick helper scripts. If you're working with one of those, please mention it.

OTHER TIPS

Joystick.js is included in Standard Assets (Mobile) package. It's also used by a plethora of other 3rd party Unity Developers such as EasyTouch, EasyJoystick, Touch UI, UI Touch, and countless others. But natively the Unity3D namespace doesn't contain Joystick like @rutter said.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top