|
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.
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.
(comments are locked)
|
|
Solved! I made a wait function
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 hold = true; timea = realtimeSinceStartup; timeb=timea+.15; while timea
(comments are locked)
|

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<timeb){ timea=realtimeSinceStartup; } hold = false;