angle add constant at vector3
I want to change mine y axis angle 20 degree less than exact angle, so i wrote the code as below
transform.rotation = Quaternion.Euler(transform.eulerAngles.x,transform.eulerAngles.y - 20f,transform.eulerAngles.z);
But the object keep rotating! How does it happen? What did I misunderstanding??
Answer by Kali2048 · Jan 17, 2016 at 03:30 AM
Why not use the Transform.Rotate() ?
transform.Rotate(0f, -20f, 0f, Space.Self)
Move this code out of the Update() method into the Start() or even it's own method, then call it only once.
Hi, thanks for your help but it's not what i want! Actually, this object(A) is connect with another object(B) which rotate in x-y plane, when B rotated by mouse A will also rotate, however I want A always parallel to y-axis, I thought maybe find a way let A object's Y-axis angle do some calculate with B object's Y-axis angle could achieve $$anonymous$$e expect. By following your suggestion $$anonymous$$e A object totally can't move while B rotating!