- Home /
Question by
axelboutry · Nov 20, 2013 at 08:29 PM ·
guimultiplayercharactercharactercontrolleroffline
multiplayer offline Character selection. Help?
The problem I am having is that The Axis is going crazy whenever I press down on the directional in which I am trying to fix it. I want it to be able to stop as soon as you press it once. If you guys need more information ask me and I will answer it asap
Another thing that I thought maybe you guys/girls could help me with is making this menu available to use with four players, one player would pick their character and as soon as a presses a button, the second player can know pick and so on and so on
Thank you here is the code
using UnityEngine; using System.Collections;
public class CharacterSelection : MonoBehaviour
{
public GUISkin guiSkin;
public float cooldown;
enum CurrentFocus {button1=1, button2=2, button3=3, button4=4}
public int currentFocus;
void Awake ()
{
Screen.lockCursor = true;
}
void Start()
{
currentFocus = (int)CurrentFocus.button1;
}
void Update ()
{
if(Input.GetKeyDown(KeyCode.JoystickButton0))
{
Application.LoadLevel(2);
}
switch (currentFocus)
{
case 1:
if (Input.GetAxis("Player1Controlx") != 0f) {
currentFocus = 2;
} else if(Input.GetAxis("Player1Controly") != 0f) {
currentFocus = 3;
}
break;
case 2:
if (Input.GetAxis("Player1Controlx") != 0f) {
currentFocus = 1;
} else if(Input.GetAxis("Player1Controly") != 0f) {
currentFocus = 4;
}
break;
case 3:
if (Input.GetAxis("Player1Controlx") != 0f) {
currentFocus = 4;
} else if(Input.GetAxis("Player1Controly") != 0f) {
currentFocus = 1;
}
break;
case 4:
if (Input.GetAxis("Player1Controlx") != 0f) {
currentFocus = 3;
} else if(Input.GetAxis("Player1Controly") != 0f) {
currentFocus = 2;
}
break;
}
}
}
void OnGUI () {
GUI.skin = guiSkin;
GUI.SetNextControlName("1");
GUI.Button(new Rect(300,255,85,100), "", "button1");
GUI.SetNextControlName("2");
GUI.Button(new Rect(525,255,85,100), "", "button2");
GUI.SetNextControlName("3");
GUI.Button(new Rect(300,450,85,100), "", "button3");
GUI.SetNextControlName("4");
GUI.Button(new Rect(525,450,85,100), "", "button4");
switch (currentFocus) {
case 1:
GUI.FocusControl("1");
break;
case 2:
GUI.FocusControl("2");
break;
case 3:
GUI.FocusControl("3");
break;
case 4:
GUI.FocusControl("4");
break;
}
}
}
Comment