- Home /
Question by
Kenshin_ · Sep 05, 2014 at 07:21 AM ·
menuselectionselectcharacters
Character Selection Menu for 2D Game
I was wondering if anybody could help me figure out how to do a character selection menu like the one in Timber man. I already have the main menu but I can not figure out how to do the character select menu. I tried using the code that I found in one of he Forums but I can't get it to work. also how would I add GUI buttons to switch between characters? and yes I have tried google, but i cant find anything that helps.
enter code here//character prefabs
public Transform character0;
public Transform character1;
public Transform character2;
//you can change this in editor or from script to load a different character
public int characterChoice = 0;
void Awake (){
//with this, the gameobject you attached the script not gonna get destroyed after loading
DontDestroyOnLoad (transform.gameObject);
}
void OnLevelWasLoaded ( int level ){
if(characterChoice == 0){
Instantiate(character0, Vector3 (0f, 37.40265f, 0f), Quaternion.identity);
}
else if(characterChoice == 1){
Instantiate(character1, Vector3 (0f, 37.40265f, 0f), Quaternion.identity);
}
else if(characterChoice == 2){
Instantiate(character2, Vector3 (0f, 37.40265f, 0f), Quaternion.identity);
}
//etc if you have more options
}
Comment