how to assign a specific device in unity 1

how to assign a specific device in unity

var p1 = PlayerInput.Instantiate(playerPrefab, controlScheme: "Gamepad", pairWithDevice: Gamepad.all[0]);
var p2 = PlayerInput.Instantiate(playerPrefab, controlScheme: "KeyboardMouse", Keyboard.current, Mouse.current);
 

Here is what the above code is Doing:
1. We’re creating a new PlayerInput object for the first gamepad that’s connected.
2. We’re creating a new PlayerInput object for the keyboard and mouse.
3. We’re assigning the PlayerInput objects to the p1 and p2 variables.

Now that we have two PlayerInput objects, we can use them to control our player prefabs.

Similar Posts