Last active
June 10, 2020 23:53
-
-
Save christopherperry/c3605499912ee0c30602100bffd84216 to your computer and use it in GitHub Desktop.
Using more than one prefab with Unity's PlayerInputManager
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using UnityEngine.InputSystem; | |
public class PlayerInputManagerHelper : MonoBehaviour | |
{ | |
public GameObject redBoxerPrefab; | |
public GameObject blueBoxerPrefab; | |
public GameEvent onRedPlayerJoin; | |
public GameEvent onBluePlayerJoin; | |
private void OnPlayerJoined(PlayerInput playerInput) | |
{ | |
if (PlayerInputManager.instance.playerPrefab == redBoxerPrefab) | |
{ | |
onRedPlayerJoin.Raise(); | |
} | |
else if (PlayerInputManager.instance.playerPrefab == blueBoxerPrefab) | |
{ | |
onBluePlayerJoin.Raise(); | |
} | |
PlayerInputManager.instance.playerPrefab = blueBoxerPrefab; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment