Skip to main content
GameDev.net gamedev.net
🔒 Locked

Analog Control Issues

Started by Illustrious Apr 5, 2009 at 1:52 PM 1 replies 800+ views
Original Post
Illustrious
Illustrious
I'm trying to make a geometry wars clone for a university project on the Nintendo Gamecube. Everything is going fine except for my controller scheme which has been a real pain to figure out; I'm hoping someone can help me. I'm trying to recreate the scheme as it is on the Xbox 360 where pushing in a direction on the analog stick will turn the ship in that direction and move in the direction it's facing. I simply cannot get this to work for me. I've tried everything, my initial attempt kept the players ship turning repeatedly. I tried using atan2 with the two values of the X and Y coords of the stick, that yielded nothing either. I've asked a lecturer who looked at me rather puzzled so I'm going to assume he doesn't know how I'd achieve this. Can anyone offer me any advice?
ApochPiQ
ApochPiQ
Off the top of my head, so no promises:

  1. Get the X,Y coordinates of the controller axis (thumbstick in this case?)

  2. Use atan2 to convert this to an angle value

  3. Rotate the unit vector (1,0) by this value

  4. This vector is now the "forward" direction of the ship

  5. Moving forward is now just a matter of converting the thumbstick X,Y pair into a "strength" value. I'd start with calculating the distance from (X,Y) to (0,0) and using that; you may want to experiment with various formulae to get a good result. Multiply the scaled strength value by the direction vector of the ship, and translate the ship by the desired amount. May require calibration for framerate-independent motion, but I assume you're familiar with that.

Illustrious
Illustrious
Great I think I've got it now with that. It's confusing as hell because all the transforms I'm doing are done with matrices and it's something I've never worked with in a game; all the 2D stuff I've done has used vectors for everything :) The ship snaps back when I let go of the stick but i think i can get that solved easily enough.

Thanks for the help

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.