-2
\$\begingroup\$

I'm trying to use a controller that has a joystick. I'd like to move the camera when the player moves the joystick. The joystick also has a button. So far I'm only seeing the camera move when the button is pressed. How can I get the camera to move even when the button is not pressed?

I added the part that handles the movement, and yes I know that the method GetButtonDown is incorrect for what i'm asking to do, but I don't see any other functions that handles the joystick movements.

protected virtual void UpdateObject(  SixenseInput.Controller controller )
{

    z += 0.5f;
    if (controller.GetButtonDown (SixenseButtons.JOYSTICK)) {
        m_initialPosition += new Vector3(0.0f,0.0f,z);
        this.gameObject.transform.position = m_initialPosition;
    }
}
\$\endgroup\$
1
\$\begingroup\$

You are literally getting the Joystick button state and only moving if it's pressed...

if (controller.GetButtonDown (SixenseButtons.JOYSTICK)) {

Just remove it. If you already know it's not correct then take it out. No need to clutter.

protected virtual void UpdateObject(  SixenseInput.Controller controller )
{    
    z += 0.5f;
    m_initialPosition += new Vector3(0.0f,0.0f,z);
    this.gameObject.transform.position = m_initialPosition;
}

Then look for controller.JoystickX and/or controller.JoystickY <- this will give you the values you need. It took 2 minutes to search in Google which gives me the impression you didn't, the API should be included with the download for the Unity Plugin - I'd highly recommend reading it.

\$\endgroup\$
  • \$\begingroup\$ yeah i know that i took the joytick button state because i didn't found something that answer my question.. so thank you for your help i'll try it :) \$\endgroup\$ – Elior Dec 8 '14 at 13:28
  • \$\begingroup\$ u3d.as/content/sixense-studios/sixense-unity-plugin/4pA The plugin says it comes with examples - did you try those? \$\endgroup\$ – Tom 'Blue' Piddock Dec 8 '14 at 13:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.