- Home /
Euler Angles problem
Hi everyone and thanks in advice!
I'm really a starter in all of this. but I'm trying to make something anyways.
My problem is that I have a 2d plane that over a 3d plane and I want the plane to rotate 35º top if I press W and 35º bottom if I press S. Im trying that with euler angles and here is the little code I have for now.
var v3Current = Vector3(90,0,0);
var v3BOT = Vector3 (0,35,0);
var v3TOP = Vector3 (0,325,0);
function Start () {
transform.eulerAngles = v3Current;
}
function Update () {
if(Input.GetKey("s")){
transform.eulerAngles = v3BOT;
}
if(Input.GetKey("w")){
transform.eulerAngles = v3TOP;
}
}
the problems I find is that the sprites appears laying down and i want it to be vertical (90º around x axis).
and that if i press S or W it will always rotate 35º bottom, like W does what S does.
anyone knows something about the problem?
Answer by hav_ngs_ru · Jun 27, 2014 at 06:09 PM
do not change eulerAngles directly. Use Quaternion instead. Quaternion.AngleAxis, for example.
Not likely to solve the problem at hand. Using Quaterions is best if you are making many small changes, prevents Gimball lock. Not going to be a problem in your case.