You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Unity新输入系统本地多人:激活第二玩家时第一玩家丢失输入设备

问题:双游戏手柄控制不同PlayerInput时,主玩家丢失输入设备
  • 场景内有两个角色:绑定了PlayerInput组件的男孩(由第一个游戏手柄控制),以及带有独立PlayerInput组件的动物同伴(计划由第二个游戏手柄控制)
  • 激活动物同伴的GameObject并启用其PlayerInput组件后,男孩的PlayerInput会丢失输入设备
    • 初始状态:Player组件初始状态
    • 激活动物后的状态:激活动物GameObject后的状态
  • 尝试调用playerInputManager.JoinPlayer(1, -1)来添加第二玩家,但无论在激活动物前后执行,问题依然存在
  • 由于两名玩家的控制逻辑不同,无法采用生成预制体的方案,想要实现类似《Spiritfarer》的合作玩法

相关代码:

public void ActivateAnimalCompanion()
{
    if (!hasSpawnedAnimal)
    {
        GManagerSingleton.instance.animal.SetActive(false);
        PlayerInput.Instantiate(GManagerSingleton.instance.animalPlayable, 1, "Gamepad1", -1, new[] { Gamepad.all[1] });
        hasSpawnedAnimal = true;
    }
}

内容的提问来源于stack exchange,提问作者Kepol

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 17:55:11