transform.rotation = Quaternion.Euler(transform.rotation.x,transform.rotation.y,transform.rotation.z * -1);
This is what I have but the z rotation just turns into 0.
Thanks.
transform.rotation = Quaternion.Euler(transform.rotation.x,transform.rotation.y,transform.rotation.z * -1);
This is what I have but the z rotation just turns into 0.
Thanks.
That’s not a problem with number variable types. That’s a problem more with rotation. What is your transform.rotation.z equal to before you multiply by -1?
This is because transform.rotation is a Quaternion, which is four numbers (x,y,z,w) and those numbers do not correspond directly to the XYZ numbers you see in the inspector. They’re always -1 to 1, and have something to do with the four-dimensional normalized direction vector of the rotation… I don’t really understand them myself TBH, but Unity’s Quaternion class means that you don’t really have to. You just have to learn to use the class.
transform.eulerAngles will get the numbers you expect in that situation… but don’t run away with this newfound information yet, because before you do, you should know that Euler angles are terrible and you should (almost) never use them.
no no…
You want to use transform.eulerAngles
When I saw that someone posted as I was writing… I thought to myself, 85% chance that’s StarManta. lol
What can I say… getting people to get rid of GameObject.Find and Euler angles is like 70% of what I do here. ![]()
Indeed. And as I respond to questions (or even ones I read but can’t help as well), I have absorbed a little bit of knowledge with rotations from you and a few other people. Little wiser for it. ![]()
This one I knew the answer, though… Just funny ![]()
Unfortunately, I had a brain dead moment as I knew that answer as well. Just happens sometimes. ![]()
For sure, I’ve responded to many posts missing one issue by seeing another… ![]()