Unity - convert Quaternion.LookAt to eulerangles?

438 Views Asked by At

Ok Im trying to rotate an object using iTween RotateTo only on 1 axis, so I have the following:

iTween.RotateTo(this.gameObject,iTween.Hash(
                                         "x", this.gameObject.transform.eulerAngles.x+90,
                                         "time", 60,
                                         "easetype", "easeInOutSine",
                                         "looptype","pingpong"
                                       ));

I've tried the iTween function that allows for rotation to a position, but I'm getting results that have the object tilting up or down depending on where the target is. I just want the y axis.

Isolating this axis, however I need to replace this.gameObject.transform.eulerAngles.x+90 with whatever the direction pointing towards the target would be. I tried Quaternion.LookAt but iTween threw a type error.

How can I convert Quaternion.LookAt to eulers?

1

There are 1 best solutions below

0
mchts On

I think what you need is to add local parameter into your rotate method to keep the up axis in gameObject's local transform:

iTween.RotateTo(this.gameObject,iTween.Hash(
                                         "x", this.gameObject.transform.eulerAngles.x+90,
                                         "time", 60,
                                         "islocal", true,
                                         "easetype", "easeInOutSine",
                                         "looptype","pingpong"
                                       ));