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.

42 lines
1.1 KiB

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