Comments and answers for "How should I rotate a 2D unit vector by X degrees?"
http://answers.unity.com/questions/729489/how-should-i-rotate-a-2d-unit-vector-by-x-degrees.html
The latest comments and answers for the question "How should I rotate a 2D unit vector by X degrees?"Answer by PsychoDuckArcade
http://answers.unity.com/answers/730067/view.html
Solved.
Converted angle from degrees to radians, since apparently sin and cos take radians despite using degrees in school, and then made sin negative since apparently the sign that sin returns isn't always consistent between math libraries.
float x = Input.GetAxis("P1MoveHorizontal");
float y = Input.GetAxis("P1MoveVertical");
float sinAngle = -Mathf.Sin(Mathf.Deg2Rad * Camera.main.transform.rotation.eulerAngles.y);
float cosAngle = Mathf.Cos(Mathf.Deg2Rad * Camera.main.transform.rotation.eulerAngles.y);
Move(new Vector2(x * cosAngle - y * sinAngle, y * cosAngle + x * sinAngle));Wed, 18 Jun 2014 17:30:04 GMTPsychoDuckArcadeComment by PsychoDuckArcade
http://answers.unity.com/comments/730010/view.html
Thanks for the answer. I Tried `motherBoard.mover.Move(Quaternion.AngleAxis(Camera.main.transform.rotation.eulerAngles.y, Vector3.up) * new Vector2(Input.GetAxis("P1MoveHorizontal"), Input.GetAxis("P1MoveVertical")));`
and
motherBoard.mover.Move(Quaternion.AngleAxis(Camera.main.transform.rotation.eulerAngles.y, Camera.main.transform.up) * new Vector2(Input.GetAxis("P1MoveHorizontal"), Input.GetAxis("P1MoveVertical")));
But it made no difference, movement still occurs relative to world not the camera.
Also just to point out, I started using rotation.eulerAngles.y instead of rotation.y as, according to another user, rotation.y is something else..Wed, 18 Jun 2014 16:08:22 GMTPsychoDuckArcadeComment by PouletFrit
http://answers.unity.com/comments/729641/view.html
Your first try, the one multiplying a quaternion with a vector should had work... Also I dont get any error when I multiply a quaternion by a vector2... What version of Unity are you using?
And if you want to rotate around the Y axis of the camera you should use transform.up and not forward. Also you talked about performance, so I suggest you to cache your camera transformWed, 18 Jun 2014 03:57:21 GMTPouletFrit