如何使用
首先得有一个PlayerInput在场景中,每一个PlayerInput表示一个玩家
在Actions里面选择自己的Actions,可以新建:
比如在PlayerMaps中的MoveActions就是一个2D向量组合器
比如新建一个
然后把键盘数字键8绑定成到UP,勾选下面的Keyboard&Mouse,这样就成了键盘的8键是我们的UP,同理绑定其他几个
然后在inspector面板中生成一下CS文件:
绑定事件
手动绑定
Send Messages或者Broadcast Messages
您可以通过定义组件,像这样的方法您的应用程序设置来响应行动:
public class MyPlayerScript : MonoBehaviour
{
// "fire" action becomes "OnFire" method. If you're not interested in the
// value from the control that triggers the action, use a method
// without arguments.
public void OnFire()
{
}
// If you are interested in the value from the control that triggers an action,
// you can declare a parameter of type InputValue.
public void OnMove(InputValue value