I’m using Unity’s new input system (input package) and would like to be able to have it where two controllers can control the same character/player. Is this possible? If so, how would I approach doing this? This may seem like an odd question but I would like to have this functionality for a game I’m working on.
Thanks in advance,
Max
EDIT: I want one player to control horizontal movement while the other player controls vertical movement of the player.
Thank you so much for your response! This is very helpful. I’m already using prefabs, player input, etc., so this should be easy to add in. I’ll tell you if it works once I have time to check.
I just realized that what your suggesting is what I already have! I don’t think my question was very clear, I wanted to say that I want to have one player control horizontal movement while the other player controls vertical movement.
Easiest approach would probably be to use UnityEngine.Input and use the Gamepad class to just detect the first two controllers connected. At least for testing purposes, this is what I would start with.
You essentially just want to be able to assign controllers to 2 separate Input Assets. The same concept for a local co-op game. You’d want your player script to be able to reference these Input Assets. Then you could assign their Inputs to different values in script. Something like
PlayerInputManager - Detects controller input to spawn additional “Players.” You can use their OnJoin and Leave properties however you choose. PlayerInputManager/Player Prefab - This won’t actually be a player prefab at all, but an empty gameobject with a PlayerInput component. Controller Script - The script that will reference the newly spawned objects and take their input.
I can’t exactly write out the whole system, but something close to this is what I use for my own multiplayer solutions (With the exception of that I don’t use PlayerInput and PlayerInputManager).