Hello,
I am trying to do a Character Selection System for my game. Currently, I have 2 Scenes, a Map-scene and a ChooseCharacter-scene. I am using 4 buttons (1 button for each character) with an Event Trigger (Pointer Click) and I have GameController with 2 Scripts. My problem is that the selected character is still spawning on the ChooseCharacter-scene and not on the map-scene.
The GameController:
Policeman button:
The Spawncharacterscript:
public class CharacterController : MonoBehaviour
{
public GameObject[] Players;
public void OnClickedOne(Button button)
{
SceneManager.LoadScene(1); // Load Scene 1
// yield return new WaitForSeconds(5); didn´t work
Vector3 pos = new Vector3(0.0f, 1.0f, 0.0f); // coords of the Player
GameObject player = Instantiate(Players[0], pos, Quaternion.identity) as GameObject; // Instantiate the first Character
}
public void OnClickedTwo(Button button)
{
SceneManager.LoadScene(1); // Load Scene 1
Vector3 pos = new Vector3(0.0f, 1.0f, 0.0f); // coords of the Player
GameObject player = Instantiate(Players[1], pos, Quaternion.identity) as GameObject; // Instantiate the second Character
}
public void OnClickedThree(Button button)
{
SceneManager.LoadScene(1); // Load Scene 1
Vector3 pos = new Vector3(0.0f, 1.0f, 0.0f); // coords of the Player
GameObject player = Instantiate(Players[2], pos, Quaternion.identity) as GameObject; // Instantiate the third Character
}
public void OnClickedFour(Button button)
{
SceneManager.LoadScene(1); // Load Scene 1
Vector3 pos = new Vector3(0.0f, 1.0f, 0.0f); // coords of the Player
GameObject player = Instantiate(Players[3], pos, Quaternion.identity) as GameObject; // Instantiate the fourth Character
}
}
The Scenecontroller:
public class SceneController : MonoBehaviour
{
public void OnMouseClick()
{
SceneManager.LoadScene(1);
}
}