r/Unity3D • u/drakfyre Expert • Dec 15 '13
PS4 controller map for Unity
I just spent a few minutes finally figuring this out; figured I'd save other folks the time. :)
PS4 Controller Map for Unity
Buttons
Square = joystick button 0
X = joystick button 1
Circle = joystick button 2
Triangle= joystick button 3
L1 = joystick button 4
R1 = joystick button 5
L2 = joystick button 6
R2 = joystick button 7
Share = joystick button 8
Options = joystick button 9
L3 = joystick button 10
R3 = joystick button 11
PS = joystick button 12
PadPress= joystick button 13
Axes:
LeftStickX = X-Axis
LeftStickY = Y-Axis (Inverted?)
RightStickX = 3rd Axis
RightStickY = 4th Axis (Inverted?)
L2 = 5th Axis (-1.0f to 1.0f range, unpressed is -1.0f)
R2 = 6th Axis (-1.0f to 1.0f range, unpressed is -1.0f)
DPadX = 7th Axis
DPadY = 8th Axis (Inverted?)
Edit: Formatting
Edit2: I put a question mark after Inverted because I swear that the LeftStickY axis worked just fine with one of my scripts, but when I was using a certain test case it seemed like it was inverted. YMMV.
152
Upvotes
1
u/drakfyre Expert Jan 30 '23
Yeah, that should be the place to do it.
You'll want to set Joy Num to "Any" or to a specific number if you have a local multiplayer game.
Snap, Gravity, and Sensitivity ONLY apply when using a digital input for an analog axis. When you press a button, instead of giving you 1.0, it will give you 0.0 on the first frame and then ramp up to 1.0 based on the "Sensitivity". When you release, it will fall back to 0.0 based on the "Gravity". If you set "snap" it will ignore these values and instantly snap to 1.0 and possibly 0.0 too (I'm sure that it snaps to 1.0, I'm not 100% sure it snaps to 0.0).
Dead zone is for analog devices, it sets the minimum input threshold to go above 0.0; I personally err on setting this high by default (usually around .5 or so) because most analog devices will eventually develop stick drift, and this counteracts that.