Hey I’m trying to generate a room using instanced static meshes. Currently I can generate a room of flat floor tiles but I wanted to now add walls to the outer edges. The maths is fine for this and I managed to get the walls to generate in the right places but now I need to rotate them to fit the room (As they are all rotated the same way at the moment)
The game definitely crashes on the SetRotation function call and when I comment it out everything else works out fine. I have also set the instanced static mesh component to movable when it is created shown here:
Assertion failed: IsRotationNormalized() [File:d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\core\public\math\TransformVectorized.h] [Line: 1257]
UE4Editor.exe has triggered a breakpoint.
The program '[2808] UE4Editor.exe' has exited with code 0 (0x0).
I feel like I’m probably being stupid but I can’t seem to find a way to make this rotation work and I need it to be able to generate the rooms properly.
The SetRotation function should work with an FRotator. Rather than using FQuat, could you try making your NewRotation variable an FRotator instead? Then, rather than .X, .Y, and .Z as the values, you would set .Pitch, .Roll, and .Yaw. This should also remove the need for MakeFromEuler() as well.
Then I don’t crash but the second I change any of the values to anything but these defaults I get the crash again (For example changing Z to 0.5f). So it must be something to do with the actual rotation of the Instanced meshes rather than the values I’m putting in.
I have also tried moving the GenerateRoom function to BeginPlay instead of OnConstruction and I get the exact same thing. Default values = no crash but changing any rotation value results in the same error as before:
As another piece of information, I found that adding a call to Rotation.Normalize(float); after setting the rotation values but before the call to Transform.SetRotation(Rotation); prevents the crash from occurring when AddInstance(Transform) is called. Can you let me know if adding this line prevents the crash for you as well?
Okay so this method solved the crashing, thank you very much! I have another problem now though that is no matter what rotation I put in, the same Quaternion values come out as seen in my log:
I’ve entered a report about the apparent crash when adding an instance through code. You can refer to this bug report here. As a work around I was able to create a blueprint from my actor class and set the rotation value of my transform variable in the construction script of the blueprint. After doing so the call to AddInstance(Transform) in code worked as expected.