Hello, I’m working on a main menu for my game. After setting up the Input Manager for use with a game pad, I wrote a basic script which should allow me to navigate through the main menu. The problem is, it’s not working as I intended. When I move the control stick up or down to scroll through the menu buttons, it starts doing so very rapidly on it’s own, and I have no control whatsoever.
Here’s the script I wrote:
#pragma strict
// The menu buttons
var thePlay : GameObject;
var theTutorial : GameObject;
var theOptions : GameObject;
var theCredits : GameObject;
var theExit : GameObject;
// The position of the button in the menu
var menuPosition : int;
// The selected button
var theSelection : GameObject;
function Start ()
{
menuPosition = 0;
theSelection = thePlay;
theSelection.renderer.material.color = Color.red;
}
function Update ()
{
if (position == 0)
{
if (Input.GetAxisRaw ("Gamepad Y") < 0)
{
menuPosition = 1;
theSelection.renderer.material.color = Color.white;
theSelection = theTutorial;
theSelection.renderer.material.color = Color.red;
}
else if (Input.GetAxisRaw ("Gamepad Y") > 0)
{
menuPosition = 4;
theSelection.renderer.material.color = Color.white;
theSelection = theExit;
theSelection.renderer.material.color = Color.red;
}
}
else if...
//And so on for all other menu positions
}
Debug.Log (Input.GetAxisRaw ("Gamepad Y");
}
Where is the problem? I’ve been striving to get this script working, three days already, and still can’t figure out what’s wrong. Could someone kindly help me?