- Home /
 
Fighting game with 2 characters and be able to change character
Hi, Im doing a Fighting game and I need to be able to change character for both player 1 and player 2. But I obviously do not know how to do this any help is appreciated. Thank you.
This question is far too broad. You haven't specified what part you need help with.
Christian. Please give us more informations about your problem.
what I want to be able to have a menu and be able to choose 2 characters for 2 diffrent players that you can play with 2 diffrent xbox gamepads, so my problem is: how do i set starting positions to player 1 and player 2 without knowing which character they will choose? can I set a variable to the gamepads?
Answer by Romano185 · Feb 27, 2012 at 02:51 PM
To select the 2 characters you can make prefabs of both of them, and assign the spawn points to the gamepads. I don't know how to assign spawn points to gamepads, but I'm sure someone knows how to do this. You can use this script to spawn the characters, assign the script to the spawning point(s):
 static var classselected : boolean = false;
 var spawnplace : Transform;
 var firstcharacterobject : GameObject;
 var secondcharacterobject : GameObject;
 
 function OnGUI () {
 
 if(classselected == false){
 GUI.Box(Rect(0,0,300,500),GUIContent("Choose your class wisely"));
 }
 
 if(GUI.Button(Rect(100,100,100,100),GUIContent("First Character")) && classselected == false ){
 var instance : GameObject = Instantiate(firstcharacterobject, spawnplace.position, spawnplace.rotation);
 classselected = true;
 }
 
 if(GUI.Button(Rect(100,200,100,100),GUIContent("Second Character")) && classselected == false){
 var instance2 : GameObject = Instantiate(secondcharacterobject, spawnplace.position, spawnplace.rotation);
 classselected = true;
 }
 }
 
 function Update (){
 if (classselected == true){
 Destroy(gameObject);
 }
 }
 
               Just assign the transform of the spawn point and the 2 prefabs in the inspector.
Lots of luck with your fighting game
Your answer
 
             Follow this Question
Related Questions
how do I set up a character selection menu? 2 Answers
Can you create characters only using unity? 1 Answer
Fighting Game Camera 1 Answer
Jumpy/flashing characters in Jumpstart game 1 Answer
2D bullet script errors. 1 Answer