- Home /
Spawning Player After Player Choice.
Hello everyone !
So this is what I need. The player will have to make a choice of what they want to play before the game starts. This of course is in a separate scene in the game.
So the player has a choice of 2 different kinds of characters, character A or character B. I have both characters already saved in a prefab. How do I make it so that it spawns what the character chose in the previous scene. I'm using C# so please make your answers in C# code.
I hope you guys understand what I need! Thanks in advance !
This ain't a request forum.
Learn basic coding, its not that hard.
Answer by SterlingSoftworks · Jan 25, 2016 at 09:28 PM
In your "character choosing" script set up two public static bools. Then when the user chooses their character set the corresponding bool to true, and the other to false.
Then in your next scene all you need to do in your "character spawning" script is, in Start() write the name of your character choosing script like so
if(characterChoosingScript.characterOneBool == true){
//Spawn character 1
}
This should be all you need to get your current request working.
If you have more than say, 4-5 characters, I'd recommend moving to an array of bools vs. individual.
Happy programming :)
Thanks for going out of your way to help me out. It's people like you that make the lives of us still learning easy. I'll accept your answer, but I haven't test the suggestion yet. For those following this question, I will post my script as soon as I can.