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;
2 years ago
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;
2 years ago
player.GetComponent<PlayerMovement>().playerNumber = playerNumber;
}
}