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

gamedev

239 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

no comments (yet)
sorted by: hot top controversial new old
there doesn't seem to be anything here