如果要Unity PS4的左右两摇杆,那么需要配置好你的Input的Name, Type, Axis, Joy Num
Name:你自己定
Type:Joystick Axis
Axis:查看下表
Joy Num:自己定用哪个
然后代码中Input.GetAxis(“NameHere”)就可以了
如下两个图:
Input设置
代码调用
那么这个Move_1的就是手柄1(Joystick 1)的左摇杆的垂直值了
水平值得可添加一个Axis改为:X axis的就好了
Axis 表
PS4手柄部位 | 轴名(Axis) | 值范围 |
---|---|---|
Left Stick X-Axis(水平) | X Axis | -1.0 ~ 1.0 |
Left Stick Y-Axis(垂直) | Y Axis | -1.0 ~ 1.0 |
Right Stick X-Axis(水平) | 3rd Axis | -1.0 ~ 1.0 |
Right Stick Y-Axis(垂直) | 6th Axis | -1.0 ~ 1.0 |
之前查了好久都不知道是哪个轴,蛋疼,还好下面的References中的国外小哥分享了
详细的Axis表
(我还是抄过来吧,也方便自己浏览)
PS4手柄部位 | 轴名(Axis) | 值范围 |
---|---|---|
Left Stick X-Axis | X Axis | -1 to 1 |
Left Stick Y-Axis | Y Axis | 1 to -1 |
Right Stick X-Axis | 3rd Axi | -1 to 1 |
Right Stick Y-Axis | 6th Axis | 1 to -1 |
DPAD X-Axis | 7th Axis | -1 to 1 (0.64 with multiple buttons) |
DPAD Y-Axis | 9th Axis | -1 to 1 (0.64 with multiple buttons) |
L1 | joystick button 4 | |
R1 | joystick button 5 | |
L2 as Button | joystick button 6 | |
L2 as Axis | 4th Axis | -1 to 1 |
R2 as Button | joystick button 7 | |
R2 as Axis | 5th Axis | -1 to 1 |
Left Stick Click | joystick button 10 | |
Right Stick Click | joystick button 11 | |
Touchpad Click | joystick button 13 | |
X Button | joystick button 1 | |
O Button | joystick button 2 | |
Square Button | joystick button 0 | |
Triangle Button | joystick button 3 | |
Share Button | joystick button 8 | |
Option Button | joystick button 9 | |
PS Button | joystick button 12 |
References
- PlayStation 4 Dual Shock Controller Input Mapping with Unity on Windows 10
- Xbox360Controller
可能需要科学上网