- Home /
Can you use an Axis to navigate a Selection Grid easily?
I'm trying to make a menu system for use with an Xbox controller and I want to walk through a selection grid with the left joystick. Unfortunately since its an axis it goes through really fast and it is rather difficult to select a specific button. I would just make it so it doesn't cycle through when you try to leave the array, but some of my menus have 3 items and it makes it difficult to select the middle element. Any ideas? Here's a code snippit.
if(Input.GetAxis("Vertical")){
var something : float = Input.GetAxis("Vertical");
if(something>0&&menu==true){ if(selGridInt >0){ selGridInt --; } else if(selGridInt ==0){ selGridInt = 2; }
}
if(something<0&&menu==true){ if(selGridInt <2){ selGridInt ++; } else if(selGridInt ==2){ selGridInt = 0; }
}
}
as you can tell, it makes it difficult to select element 1.
Solved! I made a wait function
function Wait(){ hold = true; yield WaitForSeconds(.25); hold = false; }
I used that to limit how often it got readings from the controller.
I actually had a later issue with this because I paused the time using Time.timescale = 0. What I did was change WaitForSeconds to
function wait(){ hold = true; timea = realtimeSinceStartup; timeb=timea+.15; while timea
Answer by Proggin_Barnes · May 09, 2011 at 08:15 PM
Solved! I made a wait function
function Wait(){
hold = true; yield WaitForSeconds(.25); hold = false; }
I used that to limit how often it got readings from the controller.
I actually had a later issue with this because I paused the time using Time.timescale = 0. What I did was change WaitForSeconds to
function wait(){
hold = true; timea = realtimeSinceStartup; timeb=timea+.15; while timea
Your answer
Follow this Question
Related Questions
gui list problem 2 Answers
GUI texture touch input problem 1 Answer
Input player name to a variable 2 Answers
GUI Text Area that Reads / Writes / Saves 2 Answers
How would I implement a GUI texture that acts as a slider? 0 Answers