[英]Network Client use wrong input devices when using Unity.Netcode with Starter Asset Controller (New input system)
The server is always using Keyboard and Mouse just fine.服务器始终使用键盘和鼠标就好了。
The client however always use "xbox controller" instead of Keyboard & Mouse:然而,客户端总是使用“xbox 控制器”而不是键盘和鼠标:
The following is the inspector view as a client:下面是作为客户端的inspector视图:
The Start Asset input action are unchanged, Start Asset 输入操作不变,
This is what I tried but client is still being assigned to controller:这是我尝试过的,但客户端仍被分配给 controller:
private void Start()
{
if (!IsOwner)
{
Destroy(GetComponent<PlayerInput>());
}
}
How could I fix this?我该如何解决这个问题? Other than hard coding (PlayerInput)map.SwitchCurrentControlScheme("KeyboardAndMouse");
除了硬编码(PlayerInput)map.SwitchCurrentControlScheme("KeyboardAndMouse");
? ?
This issue is fixed by disabling Player Input
script.此问题已通过禁用Player Input
脚本得到解决。
And only enable it on Network Spawn.并且只在 Network Spawn 上启用它。
public override void OnNetworkSpawn()
{
base.OnNetworkSpawn();
if (IsOwner)
{
_playerInput = GetComponent<PlayerInput>();
_playerInput.enabled = true;
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.