PixelProgrammer Posted April 13, 2017 Share Posted April 13, 2017 Hey there, So I've snagged onto a little problem while developing my game. I'm using Phaser with it's inbuilt support of gamepad. The axis of the controller input works in a way such that it returns 1 when held to the right and -1 when held to the left. Here's a picture to make things easier to understand. How would I map the values to degrees? Here's a visual representation of what I'd like to get. What's a formula that would allow me to do this? Quote Link to comment Share on other sites More sharing options...
b10b Posted April 13, 2017 Share Posted April 13, 2017 Math.atan2 will map deltas in x and y to radians. Then multiply that back to degrees if preferred. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/atan2 Nesh108 1 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.