Comments and answers for "Xbox stick vector magnitude confusion"
http://answers.unity.com/questions/870538/xbox-stick-vector-magnitude-confusion.html
The latest comments and answers for the question "Xbox stick vector magnitude confusion"Comment by Industrion
http://answers.unity.com/comments/938517/view.html
I found that, using the Xbox 360 controller driver on $$anonymous$$ac OSX, the values yield a very-rounded rectangle shape - close to a circle, but definitely not one. Can anyone shed any light on this?Thu, 02 Apr 2015 18:06:52 GMTIndustrionComment by DwaynePritchett on DwaynePritchett's answer
http://answers.unity.com/comments/871296/view.html
Check as answered then please. And, you're welcome.Wed, 07 Jan 2015 21:28:06 GMTDwaynePritchettComment by Rhombuster on Rhombuster's answer
http://answers.unity.com/comments/871168/view.html
Thanks guys, I was laying in bed last night and realized this was just the unit circle from my calc class. I hate how it seems like you always figure something out when you're doing nothing even though you spent a couple hours lost and frustrated. I haven't tried your code but that is definitely what I wanted. Thanks so much for the help guys.Wed, 07 Jan 2015 18:46:33 GMTRhombusterAnswer by DwaynePritchett
http://answers.unity.com/answers/870594/view.html
I don't know if I understand the issue...but...
The thing is, at best you can only give each of the inputs a 45 degree threshold. Because, 360/8 is 45.
I think you aren't considering the fact that the space around the Xbox's Analog stick isn't a square, but rather a circle. If it was normalized it would be (0.707,0.707) approximately. Because, a 45 degree angle is (root2/2). Since, you're getting some 0.8 values, the circular shape around the stick must not be a perfect "Unit Circle".
I would make a Quaternion and return the 2D Rotation Equivalent of my input as some degrees. Then use that to determine the direction you are pushing. Where,(-22.5,22.5) is Right.(22.5,67.5) is UpRight etc.
I feel like Unity has this built in, but I don't know what off the top of my head.
Hope this is somewhat helpful at least.Wed, 07 Jan 2015 12:28:23 GMTDwaynePritchettAnswer by DwaynePritchett
http://answers.unity.com/answers/870613/view.html
I didn't actually test it. But you should be able to use this and then just check in between what ranges you want.
float GetInputAngle(float xInput, float yInput){
//Get the angle ignoring quadrant. Call it rawAngle.
float absX = Mathf.Abs(xInput);
float absY = Mathf.Abs(yInput);
if(xInput > 0){
float rawAngle = Mathf.Rad2Deg*Mathf.Atan(absY/absX);
if(yInput > 0){
return rawAngle;
}
if(yInput < 0){
return 360 - rawAngle;
}
if(yInput == 0){
return 0;
}
}
if(xInput < 0){
float rawAngle = Mathf.Rad2Deg*Mathf.Atan(absY/absX);
if(yInput > 0){
return 180 - rawAngle;
}
if(yInput < 0){
return 180 + rawAngle;
}
if(yInput == 0){
return 180;
}
}
if(xInput == 0){
if(yInput > 0){
return 90;
}
if(yInput < 0){
return 270;
}
if(yInput == 0){
//This means no input.
return -1;
}
}
return -1;
}
![alt text][1]
[1]: /storage/temp/38352-anglediagram.pngWed, 07 Jan 2015 11:43:06 GMTDwaynePritchettComment by HYPERSAVV
http://answers.unity.com/comments/870704/view.html
Pushing the gamepad stick around the edge will give you points along the outside of a circle. (1, 1) would lie outside of that. $$anonymous$$eyboard input is digital (compared to the analog gamepad stick) and is either 0 (not pressed) or 1 (pressed).Wed, 07 Jan 2015 07:45:21 GMTHYPERSAVV