Jump to content

How to map a range from [-1, 1] to 360 degrees?


Recommended Posts

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.

axis.png.0924fbee7bbc24d1e07983cb002a43eb.png

 

How would I map the values to degrees? Here's a visual representation of what I'd like to get.

axisWanted.png.019de4282b47cfdae5bbb6ec8fcfb92a.png

 

What's a formula that would allow me to do this?

Link to post
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...