- Home /
A simple character selection screen,Help with characters selection screen
Hi, I'm trying to create a characters selection screen where you click on one character, and then being launched to the game screen.
I've got two characters, a boy and a girl both are set as 'childs' of two UI buttons, with no special traits or qualities for the characters. My 'demand' from the game is to click on the girl and then she will spawn in the game, same as the boy. The game Scene should be the same for both of them.
Needless to say, i'm a beginner and having trouble finding a proper code, or info about it.
Would appreciate a link or any function that might assist. Thanks!
Answer by Larry-Dietz · Dec 25, 2017 at 10:25 PM
You could use PlayerPrefs to save their selection, then in the game scene, read the entry from playerprefs and instantiate the correct prefab.
i.e.
In your selection screen, assuming a variable named Selection contains the work Boy or Girl
PlayerPrefs.SetString("Selection",Selection);
then in the game scene, were you are instantiating the player.
string Selection = PlayerPrefs.GetString("Selection");
switch (Selection){
case "Boy":
//Instantiate Boy prefab here
break;
Case "Girl":
//Instantiate Girl prefab here
break;
}
Hope this helps, -Larry
Your answer

Follow this Question
Related Questions
Character selection 1 Answer
Character Selection (Change Material) 0 Answers
Character Selection 0 Answers
Character development with abilities 1 Answer
Using a selected character 1 Answer