背景

步骤
打开设置面板
Edit->Project Settings->Input,你可以看到下面的界面

知识点:
这个一个数组结构,所以图里【axes】下一共是15项,每一项通过一个名字设置一个按键的属性,比如我们常用的[Horizontal]。
[Horizontal]可以在代码中调用,就像这样
value = Input.GetAxis ("Horizontal");
那么属性里面这两个很重要

操作步骤
确保在默认设置中,删除了wasd的控制
更改数组下方另外一套按键设置,改名字和按键。这样你就可以通过Horizontal2来获取player2的输入

OJBK!
这里是其它按键的名字
Keys
The names of keys follow this convention:
- Normal keys: “a”, “b”, “c” …
- Number keys: “1”, “2”, “3”, …
- Arrow keys: “up”, “down”, “left”, “right”
- Keypad keys: “[1]”, “[2]”, “[3]”, “[+]”, “[equals]”
- Modifier keys: “right shift”, “left shift”, “right ctrl”, “left ctrl”, “right alt”, “left alt”, “right cmd”, “left cmd”
- Mouse Buttons: “mouse 0”, “mouse 1”, “mouse 2”, …
- Joystick Buttons (from any joystick): “joystick button 0”, “joystick button 1”, “joystick button 2”, …
- Joystick Buttons (from a specific joystick): “joystick 1 button 0”, “joystick 1 button 1”, “joystick 2 button 0”, …
- Special keys: “backspace”, “tab”, “return”, “escape”, “space”, “delete”, “enter”, “insert”, “home”, “end”, “page up”, “page down”
- Function keys: “f1”, “f2”, “f3”, …
<small>来源: https://docs.unity3d.com/Manual/ConventionalGameInput.html</small>
网友评论