FQuat FRotation The transformed changes

As you can see in the above code, after the conversion, use the “Set Actor Transforms” function to set the position and rotation of a certain Actor. Then the rotation of the Actor became 180, 90, 180. Sometimes it became 75.9638, 90, 165.9638. (roll, pitch, yaw). If the pitch setting is less than 90, such as 0.0, 89.999, 90; one can obtain 0.0, 89.999, 90. I know that pitch represents values ranging from 0 to 180 or -180. Is there any connection? How can we ensure the consistency of the conversion? Although the rotation of the Actor in space is correct.

Couple of tips. Name your variables starting with lowercase of what they are (tObject or rRot) so that you just know what to set them to down the pipeline.

And eright click the function and analyze it. Even Re-write your own. Sanitize the variables values or at least check if they are double or float.

I think the baseline issue is a wrong conversion or “lost precision”.

Also, make sure that setting roll/pitch/yaw that way works. If my theory is right, it doesn’t. Each value you set likely causes the transform to recalculate rather then just set the value I believe.

Last but not least. There are different options to set a transform. Some automatically take into account the current rotation of an actor. Some do not. Make sure to use the correct version of the function (if memory serves its an option in the function call).

Also, quaternions aren’t avaliable to BP afaik. So you cant make a blueprint callable function and expect fquat as an input (not that you are, just something to keep in mind if you are hoping to fight gymbal lock).

Thank you for your reminder. >.<

YES. I believe the rotation data of Transform is stored in the FQuat format. The transformation that occurs when using SetRotation. May I ask, is there any effective way to change the rotations of one or more characters by directly setting the Euler angles? Of course, I need to use Transform because this type is saved in the archive. If directly store a FRotator, need to modify a lot of things.

The function I want to implement is similar to that in the UE5 editor. You can select an object and set its position and rotation. The current code allows for setting the rotation and position of the object, but the rotation I re-read turned out to be very strange. (Only when pitch is greater than or equal to 90 or less than or equal to -90).

There is a difference between ‘set’ and ‘update’.

One would take current rotation into account and add to it, the other would not.

If I got you correctly.

Create a rotator with the needed values FRotator(Pitch, Yaw, Roll), create a quaternion with that rotator (this actually calculates the values).

Then you feed the quaternion to the proper function.

I think AddActorRotation or something similar to that is the one you want.

As I recall there was a bug with the engine crapping out when the pitch reaches 90. Which is exactly what you are describing… try directly searching for the bug, and you may even get proper code examples with the right function calls rather than what I recall :winking_face_with_tongue:

This is a good idea. I’ll give it a try.