Hello,
I’m new to unity, and I’m trying to implement a game with the new input system that requires two separate prefabs to be controlled with two controllers. The characters don’t need to be spawned in, but I was able to get both controllers working separately by spawning in the same prefab twice, which is only helpful in that I know the system works. I’d really prefer it if the prefabs could be already in the game by default, actually.
Is there a way to get the new input system to work with multiple prefabs? I was searching in the PlayerInputManager script to see if there was something I could add there to provide an additional prefab slot or something, but frankly I don’t know how that would work.
I’d appreciate some pointers to make this work!
Thank you!
If you want to have pre-spawned players in the game instead of having them join lobby-style, you can simply put instances of your player prefabs in the scene and save it like that.
Note that there’s limited control this way over what devices the players end up with. You can control it to some extent by setting the default control scheme on each player. However, if you want both players to use the same control scheme but use specific devices with those, that cannot be configured solely through the properties at design time.
However, you can still control it in script. I.e. after the game has started, you can assign devices individually to each player using, for example, PlayerInput.SwitchCurrentControlScheme.
var player1 = PlayerInput.all[0];
var player2 = PlayerInput.all[1];
player1.SwitchCurrentControlScheme("Gamepad", Gamepad.all[0]);
player2.SwitchCurrentControlScheme("Gamepad", Gamepad.all[1]);
Thank you! I think I’ve got it figuring out! Only now, one of the players kinda drifts when I’m not using the left stick. I don’t suppose you would know what that’s about off-hand, do you?