- Home /
PS4 Analog Sticks Are Not Analog?
I have this weird situation happening to me when I attempt to use the PS4 controller with unity. Mainly with the axes of the control sticks (both the left and right control stick), they are registering as digital input instead of analog input. I set up the input manager correctly (I double checked that part), and I will put up the code here if anyone spots what I am doing wrong. I have also plugged in the PS4 controller to my windows 7 machine and the drivers that were installed seem to work fine (no calibration was needed) and unity has detected the controller with no problem.
The real problem begins here: Upon testing the input of the controller, I get this without touching the control sticks.
Here is the code for the axes:
void Update()
{
//------------PS4 controller axises-----------------
dPadX = Input.GetAxis("Dpad X");
dPadY = Input.GetAxis("Dpad Y");
leftAnalogX = Input.GetAxis("leftAnalogX");
leftAnalogY = Input.GetAxis("leftAnalogY");
rightAnalogX = Input.GetAxis("rightAnalogX");
rightAnalogY = Input.GetAxis("rightAnalogY");
if(dPadX < -0.1f)
{
Debug.Log("DPad: Going left");
}
if(dPadX > 0.1f)
{
Debug.Log("DPad: Going right");
}
if(dPadY < -0.1f)
{
Debug.Log("DPad: Going down");
}
if(dPadY > 0.1f)
{
Debug.Log("DPad: Going up");
}
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");
}
}
What am I doing wrong that is causing this problem?
Using a figure of 0.1? Thats barely out of the deadzone.
Place an OnGUI routine in there, make a label and insert your axis variables to it. Observe directly on screen the values you are returning from the sticks without relying on discreets.
The reason I have it set up like this is because I need the precision of 0.1.
I have the GUI labels set up and it shows this:
It is getting the same results as the problem mentioned.
Here is the GUI code I am using:
void OnGUI()
{
GUI.Label(new Rect(10, 0, 100, 30), "DPad X: " + dPadX);
GUI.Label(new Rect(10, 40, 100, 30), "DPad Y: " + dPadY);
GUI.Label(new Rect(10, 80, 100, 30), "leftAnalogX: " + leftAnalogX);
GUI.Label(new Rect(10, 120, 100, 30), "leftAnalogY: " + leftAnalogY);
GUI.Label(new Rect(10, 160, 100, 30), "rightAnalogX: " + rightAnalogX);
GUI.Label(new Rect(10, 200, 100, 30), "rightAnalogY: " + rightAnalogY);
}
But I will continue to work on this, and I am trying a few ideas to see if something works to get this controller working with Unity.
Your answer
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Controller Axes Rotational Input 2 Answers
game controller YES but not all axes are working 1 Answer
Using an Xbox 360 controller for Rotation 0 Answers
MMD How to export model and animations to Unity as 3rd person controller? 2 Answers