# Mapping unit circle to rectangle (gamepad stick input)

## Recommended Posts

bzroom    647
When mapping a gamepad stick to XY controls, such a for a vehicle (steering/throttle) you lose a bit of control in the corners. You can't have full steer and full throttle. I'm curious what people do to fix this problem. I was thinking of taking the X value raw, and the computing the Y value in terms of the maximum possible Y value for the given X. This sounds kind of unstable though, at full X stick the maximum Y value is zero, or very close to it. This will make any slight Y movement twitch from 0 to full + or - Y.

##### Share on other sites
Codeka    1239
Most racing games use a different button for "accelerate" and "brake". The left analog stick is just for steering. On the Xbox controller, you can use the trigger buttons for accelerate if you want to provide an "analog" acceleration button (otherwise, most of them use "X").

##### Share on other sites
bzroom    647
I agree, usually i'd use separate controls, probably the triggers. But this is for basic movement. Not realistic racing movement. So like say it where controlling a character. How would one remove the dead spots in the corners?

##### Share on other sites
Zipster    2365
I imagine then it's based on angle/distance, where the angle is which direction to move in and the distance (amount of tilt in the analog stick) is the speed. That's how it feels with most 3rd person games which use such a control scheme.

##### Share on other sites
swiftcoder    18437
Quote:
 Original post by bzroomI agree, usually i'd use separate controls, probably the triggers. But this is for basic movement. Not realistic racing movement. So like say it where controlling a character. How would one remove the dead spots in the corners?
What dead spots in the corners? For that matter, what corners?

The character moves with the same top speed no matter the direction, so rather than thinking about the stick as representing two independent axis, treat it as representing a direction and a magnitude.

##### Share on other sites
aleks_1661    188
Had this one in my delicious bookmarks:

http://theinstructionlimit.com/?p=531

Regards,

Alex

##### Share on other sites
bzroom    647
Thanks everyone, especially aleks_1661.

Bad analogy on my part with the character. It's not for a character.

This blog seems to have plenty of information to hold me over. Thank you.