How to convert x,y coordinates to an angle?
Hey guys sorry for the basic question, i am quite new in Unity. I have a x and y coordinate (from -1 to +1 (unit circle)) and I want to convert them to an angle so I can rotate my gameobject around that angle.
int myY= leftController.GetTouchPosition.y;
int myX = leftController.GetTouchPosition.x;
//myAngle = ........ //calculation
//transform.Rotate(myAngle);
Comment
Answer by FortisVenaliter · Aug 07, 2017 at 04:35 PM
Check out Mathf.Atan2().
Note that it returns Radians though, so you may need to convert to degrees.
FortisVenaliter thanks, but I get this error: System.$$anonymous$$ath' does not contain a definition for
atan2'....... Any ideas?
Use $$anonymous$$athf.Atan2, System.$$anonymous$$ath is not the same as Unity $$anonymous$$athf class
Yeahh that was the bug thx... but the problem is that after the rotation I cant move the character. It just spins al the time.......