- Home /
Gamecube Controller joystick axis does not work?
I am trying to get a Gamecube controller to work with Unity 5. I have connected the Gamecube controller to the Wii U adapter that is then connected to my laptop. The controller is calibrated correctly (according to windows 10) and I am using vjoy and/or a device called WUP-028 that gets the input. Most of the components of the controller work (mainly the buttons and the DPad), except the joystick axis (control stick, c-stick, and the analog L and R buttons (I can still get the regular L and R buttons as digital inputs)).
My question is where/how to get the axis on this joystick correctly? I am getting an issue where it is getting input, but it is either 1 or -1 (and I am looking for the range in-between those numbers). Here is the script I have that gets the controller inputs:
using UnityEngine;
using System.Collections;
public class GameCubeController : MonoBehaviour
{
//GameCube control variables
[Tooltip("The x-axis for the Control stick.")]
public float leftAnalogX = 0f;
[Tooltip("The y-axis for the Control stick.")]
public float leftAnalogY = 0f;
[Tooltip("The x-axis for the C-Stick stick.")]
public float rightAnalogX = 0f;
[Tooltip("The y-axis for the C-Stick stick.")]
public float rightAnalogY = 0f;
[Tooltip("The axis for the L Button.")]
public float leftAnalogButton = 0f;
[Tooltip("The axis for the R Button.")]
public float rightAnalogButton = 0f;
//Update is called once per frame
void Update()
{
//------------GameCube controller axises-----------------
leftAnalogX = Input.GetAxis("leftAnalogX");
leftAnalogY = Input.GetAxis("leftAnalogY");
rightAnalogX = Input.GetAxis("rightAnalogX");
rightAnalogY = Input.GetAxis("rightAnalogY");
leftAnalogButton = Input.GetAxis("leftAnalogButton");
rightAnalogButton = Input.GetAxis("rightAnalogButton");
if(leftAnalogX < -0.1f)
{
Debug.Log("leftAnalog: Going left");
}
if(leftAnalogX > 0.1f)
{
Debug.Log("leftAnalog: Going right");
}
if(leftAnalogY < -0.1f)
{
Debug.Log("leftAnalog: Going up");
}
if(leftAnalogY > 0.1f)
{
Debug.Log("leftAnalog: Going down");
}
if(rightAnalogX < -0.1f)
{
Debug.Log("rightAnalog: Going left");
}
if(rightAnalogX > 0.1f)
{
Debug.Log("rightAnalog: Going right");
}
if(rightAnalogY < -0.1f)
{
Debug.Log("rightAnalog: Going up");
}
if(rightAnalogY > 0.1f)
{
Debug.Log("rightAnalog: Going down");
}
if(leftAnalogButton > 0.1)
{
Debug.Log("L button has pressure");
}
if(rightAnalogButton > 0.1)
{
Debug.Log("R button has pressure");
}
//--------------GameCube controller buttons-------------
if(Input.GetButtonDown("A_Button")) //Joystick button 0
{
Debug.Log("A button pressed");
}
if(Input.GetButtonDown("B_Button")) //Joystick button 1
{
Debug.Log("B button pressed");
}
if(Input.GetButtonDown("X_Button")) //Joystick button 2
{
Debug.Log("X button pressed");
}
if(Input.GetButtonDown("Y_Button")) //Joystick button 3
{
Debug.Log("Y button pressed");
}
if(Input.GetButtonDown("Z_Button")) //Joystick button 4
{
Debug.Log("Z button pressed");
}
if(Input.GetButtonDown("R_Button")) //Joystick button 5
{
Debug.Log("R button pressed");
}
if(Input.GetButtonDown("L_Button")) //Joystick button 6
{
Debug.Log("L button pressed");
}
if(Input.GetButtonDown("Start")) //Joystick button 7
{
Debug.Log("Start button pressed");
}
if(Input.GetButtonDown("DPad_Up")) //Joystick button 8
{
Debug.Log("DPad Up pressed");
}
if(Input.GetButtonDown("DPad_Down")) //Joystick button 9
{
Debug.Log("DPad Down pressed");
}
if(Input.GetButtonDown("DPad_Left")) //Joystick button 10
{
Debug.Log("DPad Left pressed");
}
if(Input.GetButtonDown("DPad_Right")) //Joystick button 11
{
Debug.Log("DPad Right pressed");
}
}
}
Here is what issue I am experiencing when I enter play mode:
Here is what I have in the input manager. All six axis are similar to what you see here, the only diference is the name and the axis for each.
I have searched for answers to this problem for awhile now, and there is not much out there. There is one question on this site that addresses the Gamecube controller, but is not having the same problem as I am facing right now. Any help is appreciated and please let me know if there is any way to fix this problem.
Hi! I'm sitting with this exact problem right now. I can get the buttons but not the axis. Did you find a solution to this? @AmasterAmaster