- Home /
Question by
biebuster · Sep 28, 2015 at 06:12 PM ·
rotationxboxcontrolleranalog
need 2d object to face the angle of the analog stick
I have this thing:
View post on imgur.comNow i would like this 'thing' to rotate based on the angle of the analog stick. So if you had you're analog stick at this angle: [img] http://i.imgur.com/GYVU9wj.png[/img] it should go like this: [img] http://i.imgur.com/hIsY6NI.png[/img] Now, i have no problem getting the data from the analog stick, or getting the dead zones to work proberly. now i don't know how to use this data to any thing, because if you hold the analog stick to the right, it will give you "1" if you hold it upwards it will give you "1" too though. I've tried lots of things with the code. Timing the vertical numbers with 10, using quaternions, but i can't get it to work. My current code looks like this:
float xAxis;
float yAxis;
void Update () {
xAxis = Input.GetAxis ("Horizontal");
yAxis = Input.GetAxis ("Vertical");
//insert magical thing that makes the object rotate here!
Any help is much appreciated.
reminder: it's a 2d object
Comment
http://docs.unity3d.com/ScriptReference/$$anonymous$$athf.Atan2.html
This will get you started.