this post was submitted on 16 Dec 2023
25 points (100.0% liked)

gamedev

219 readers
1 users here now

Game Development

Free Resources List

founded 1 year ago
MODERATORS
 

So I'm doing a VR experience and today I'm working on using the thumbsticks of the quest controller more like a gamepad to control selection of a UI menu for a trivia game that's going to be in the experience.

Now Unity returns the thumbstick via a Vector2, easy enough. I literally sketch out an XY graph, figure there's a threshold I need to account for for each direction, a much smaller threshold that we can ignore for each plus and minus on the other vector, and if the Vector2 meets all my criteria I can fire off my functions for the direction. So for UP my code looks something like

if(Vector.Y > pressthreshold and (Vector.X < threshold and Vector.X < -threshold){ Print(up!)}

And then I did that for each direction... And it kinda worked. But it was wonky as hell because my quest is old and the thumbsticks drift. So I spent like an hour and a half trying to find just the right thresholds and it just did not want to be consistent...

So I figured I'd ask chatgpt. And it basically spits out: Just take the absolute value of your X and Y and whichever one is bigger is your plane, and then the positive or negative of the value determines your direction.

ARE YOU FUCKING KIDDING ME?

I am in shambles. I have once again overcomplicated the simplest freaking thing.

TLDR: My brain is pudding. Just had to vent. doomer

top 7 comments
sorted by: hot top controversial new old
[–] [email protected] 14 points 11 months ago (1 children)

that's how the process of learning works, but for some reason, when it comes to programming, instead of getting the "aha" of solving a puzzle, we get a "d'oh, how could i have been so stupid", it's fucked up

[–] [email protected] 8 points 11 months ago

Indeed. Even more frustrating is I'm pretty sure I did this exact same thing when I wrote an app on the oculus go years ago.

[–] [email protected] 7 points 11 months ago* (last edited 11 months ago) (2 children)

fwiw that doesn't reject diagonal inputs, you may want to do something similar to what chatGPT said except with a threshold, i.e. if the |x| : |y| ratio isnt, say, less than 0.8 or more than 1.2, you can reject the input as being too close to a diagonal input.

Only bother with this if you actually want to reject diagonals of course, this is especially not useful for menuing in a list that's only horizontal or only vertical navigation.

[–] [email protected] 2 points 11 months ago

yeah you might want to have people try it out a little bit because ive found that having thresholds right in the middle can feel weird (granted not for gamedev but for other rotating things)

[–] [email protected] 2 points 11 months ago (1 children)

Yeah, preventing diagonals was my original intention with the secondary threshold, but these thumbsticks are so unreliable that I think I'm better off sticking to a single axis. Originally I was gonna go with a grid of 2 x 2 for my answers, but there's no reason I can't simplify them to a single column. Also, this trivia thing is occurring within the confines of a lewd game so simplifying it would also probably help with keeping the player from getting flustered. I am intending a time limit on it.💁‍♂️

[–] [email protected] 2 points 11 months ago* (last edited 11 months ago) (1 children)

If that's the case, you might want to arrange your options in a diamond and have selection work as up/left/right/down, and instead of navigating and pressing A, have option select be by holding the stick in a cardinal direction for a duration. Sort of like how a weapon wheel works. I'm struggling to think of an example that's been implemented somewhere that makes this more clear but I'm gonna go scour youtube real quick

e: it's called a radial menu. Possibly consider a radial menu - all you have to do is take a tan(x_value / y_value) and compare it to some ranges for up/left/down/right, it's button-free and from a UX perspective it's less likely to result in a misinput

If it's not like a core mechanic of the entire game don't go to all this trouble though lmao I'm just passionate about UX

[–] [email protected] 1 points 11 months ago

Oooh. I don't know if I'll implement it, but that is a good idea, thanks! It's certainly got the juices flowing. Anything that reduces the amount of times they fumble around looking for a button would be helpful.

I didn't play it but didn't Mass Effect do something like that with their dialogue options?