I have a really strange problem and I don’t know what causes this problem.
I have an actor placed into the level. It’s a farm with multiple plants, and on “initializing” they are all rotated randomly. These plants are all instances of one InstancedStaticMeshComponent. For debugging I don’t actually use the mesh of plants, but just one of the standard pillars. So they are clearly not affected by wind or any other physics!
I have a function. This function is being called at EventBeginPlay by a timer which executes once every second. You can see the timer here:
Nothing special. This is the function:
I do a loop for every instance (for debugging I only have one instance!), get the old transform, set only the scale to something new and update the transform of the instance. I only added the variable LTransform for debugging, I also could just directly calculate the new transform and use it for updating. The location and rotation is directly used from the “old” transform.
You see I have a “Print String” there which prints the rotation of the instance. Since I only have one instance, it should just print the same thing once every second, since the function is only executed once every second, and the rotation is never changed.
So that’s the problem: The rotation actually changes. Here is what the function prints out:
PIE: Info Play in editor start time for /Game/Assets/Maps/UEDPIE_0_TestMap 2.895 LogBlueprintUserMessages: Start LogBlueprintUserMessages: P=-0.000000 Y=-5.526306 R=-0.000000 LogBlueprintUserMessages: Start LogBlueprintUserMessages: P=0.000000 Y=0.000000 R=-0.000000 LogBlueprintUserMessages: Start LogBlueprintUserMessages: P=0.000000 Y=0.000000 R=-0.000000 LogBlueprintUserMessages: Start LogBlueprintUserMessages: P=0.000000 Y=0.000000 R=-0.000000 LogBlueprintUserMessages: Start LogBlueprintUserMessages: P=0.000000 Y=0.000000 R=-0.000000
The first time the function is executed, there still is a rotation. Since the second time, there is no longer any rotation.
I now added a breakpoint on the right “Set LTransform”. On the first execution, it looks like this:
You see that actually the exact rotation which is get is also set. Nothing changed, all works.
Now the second execution:
Suddenly, there is no rotation! It’s just gone. While the transform of the instance was updated, the rotation was just set to 0/0/0. Funny thing is, the location (which is set and get in the exact same way!) has not changed, it is the same, no problem for location.
I dont do anything to the rotation in another function. The actor is just placed into the level in the editor, not referenced in any other blueprint. It’s just the timer running, no other stuff related to this actor is executed.
So it’s really strange. I even tried restarting the editor, but that has not changed anything. Do you have any idea what could cause this? Is this a bug with “UpdateInstanceTransform”?