What ever I spawn an object in Awake() it gets spawned twice.
This is the script:
using UnityEngine;
using System.Collections;
public class SpawnPoint : MonoBehaviour {
public GameObject PlayerPrefab;
// Use this for initialization
void Awake() {
SpawnPlayer();
}
void Start () {
}
// Update is called once per frame
void Update () {
}
public void SpawnPlayer() {
Instantiate(PlayerPrefab, transform.position, Quaternion.identity);
}
}
I do not. I attached an image, there very few things in the scene, there is only one spawn point besides the function to spawn the Player gets also called whatever the player dies and when that happens only one Player is spawned. if I had multiple copies of the script then it would also spawn multiple players GameObjects when the player dies not just in Awake().
I also tried running if (Player == null) before calling spawn player with the same result, duplicated player.
Nope, but I was about to edit my post to say I discovered what it was, I didn’t had a second script (like i said then it would have spawned two players always and not only in Awake()) but what happened was the Gamemanager had the bool IsDead set to true even though I have it set to false by default in the script, I might have set it to true by mistake in the editor at some point. Totally my fault.