Is there any way to enable sixaxis support for PS3 controllers on PC in Unity. Either via plugin or native support. I’ve googled around a little bit and didn’t find anything (I could also have done an insufficient job). Thanks!
On OSX, at least, it seems to plug in and work fine, and wirelessly as well. I used the following basic script (csharp, but a JS port would be easy) to map out the buttons. Put this code block into void OnGUI()…
GUI.Label( new Rect(20,20,400,20), "Active Joystick: " + Input.GetJoystickNames()[0] + ".");
float yOffset = 40.0f;
int buttonIndex = 0;
if(Input.GetKey(KeyCode.JoystickButton0)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Select");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Select");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton1)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Left Joystick Press");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Left Joystick Press");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton2)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Right Joystick Press");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Right Joystick Press");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton3)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Start");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Start");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton4)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Up");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Up");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton5)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Right");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Right");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton6)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Down");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Down");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton7)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: D-Pad Left");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: D-Pad Left");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton8)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Left Trigger");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Left Trigger");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton9)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Right Trigger");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Right Trigger");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton10)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Left Bumper");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Left Bumper");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton11)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Right Bumper");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Right Bumper");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton12)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Green / Triangle / Upward");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Green / Triangle / Upward");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton13)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Red / Circle / Rightward");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Red / Circle / Rightward");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton14)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Blue / X / Downward");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Blue / X / Downward");
}
yOffset += 20.0f;
buttonIndex++;
if(Input.GetKey(KeyCode.JoystickButton15)) {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " on: Pink / Square / Leftward");
} else {
GUI.Label (new Rect (20, yOffset, 500, 20), "Joy button " + buttonIndex.ToString() + " off: Pink / Square / Leftward");
}
yOffset += 20.0f;
buttonIndex++;
GUI.Label (new Rect (20, yOffset, 500, 20), "Left Thumbstick: " + Input.GetAxis("L_XAxis_0").ToString("f1") + "," + Input.GetAxis("L_YAxis_0").ToString("f1"));
yOffset += 20.0f;
GUI.Label (new Rect (20, yOffset, 500, 20), "Rite Thumbstick: " + Input.GetAxis("R_XAxis_0").ToString("f1") + "," + Input.GetAxis("R_YAxis_0").ToString("f1"));
} // End Playstation 3 controller
Very best of luck to you. Note that you would need to define L_YAxis_0 and L_YAxis_0 and L_XAxis_0 and R_XAxis_0 in the Edit → Project Settings → Input editor (Joystick axes).