- Home /
get euler rotation from horizontal and vertical axis values
Hi, I am trying to rotate my character depending on the value coming from the joystick. is there a way without putting full blown trigonometry into my script to convert the horizontal and vertical axis values to a euler angle. so if Input.GetAxis("Horizontal") == 1 and Input.GetAxis("vertical") == 1 the euler angle would be 45. and if Input.GetAxis("Horizontal") == 1 and Input.GetAxis("vertical") == -1 the euler angle would be 135.
i only know how to do this with a ton of if else statements. im sure there is a better way, i just cant find the right function.
Answer by Proportion1 · May 15, 2013 at 06:52 AM
if it helps i did the trig:
((Mathf.Atan2(Input.GetAxis("Horizontal"), Input.GetAxis("Vertical")) * (180 / Mathf.PI))
Cool nice tip. I think you have an extra bracket in there