You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

31 lines
795 B

using UnityEngine;
public class PlayerSpawnPoint : MonoBehaviour {
public GameObject defaultPlayerPrefab;
public int playerNumber;
void Awake(){
//get selected player from character selection screen
if(GlobalGameSettings.Player1Prefab) {
loadPlayer(GlobalGameSettings.Player1Prefab);
return;
}
//otherwise load default character
if(defaultPlayerPrefab) {
loadPlayer(defaultPlayerPrefab);
} else {
Debug.Log("Please assign a default player prefab in the playerSpawnPoint");
}
}
//load a player prefab
void loadPlayer(GameObject playerPrefab){
GameObject player = GameObject.Instantiate(playerPrefab) as GameObject;
player.transform.position = transform.position;
player.GetComponent<PlayerMovement>().playerNumber = playerNumber;
}
}