x


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.

more ▼

asked May 07 '11 at 06:10 AM

Proggin_Barnes gravatar image

Proggin_Barnes
36 4 6 13

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.

May 07 '11 at 06:45 AM Proggin_Barnes

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;

May 09 '11 at 08:11 PM Proggin_Barnes
(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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

more ▼

answered May 09 '11 at 08:15 PM

Proggin_Barnes gravatar image

Proggin_Barnes
36 4 6 13

(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3673
x952
x38

asked: May 07 '11 at 06:10 AM

Seen: 785 times

Last Updated: May 07 '11 at 06:10 AM