- Home /
Question by
TrojanFM · Feb 25, 2012 at 03:14 AM ·
javascriptrotate
change the rotation
hey ,
i want to rotate an object to (270,0,180) if the player rotation is (90,90,0) or (270,270,0) but else that i want to rotate the object to (270,0,0)
could someone code this in javascript ?
Thanks !
Comment
Best Answer
Answer by Kleptomaniac · Feb 25, 2012 at 10:27 AM
Unity is all about learning! You can't just make people write your scripts for you. However, it's a relatively simple script. I'll give you some pseudo code which you can extrapolate on:
if (player.transform.rotation == Quaternion.Euler(270,0,180) || player.transform.position == Quaternion.Euler(270,270,0)) {
object.transform.rotation = Quaternion.Slerp(startRotation), Quaternion.Euler(270,0,180), Time.time * 0.1);
} else {
object.transform.rotation = Quaternion.Slerp(startRotation, Quaternion.Euler(270,0,0), Time.time * 0.1);
}
}
For more info on Quaternion.Euler and Quaternion.Slerp, go here and here.
Hope this helps! Klep
Your answer
![](https://koobas.hobune.stream/wayback/20220613064420im_/https://answers.unity.com/themes/thub/images/avi.jpg)