Spawned Actor getting weird Transform Values

Hi!

I’m trying to spawn e.g. a directional light:

ADirectionalLight* DirectionalLight = (ADirectionalLight*)GetWorld()->SpawnActor(ADirectionalLight::StaticClass(), &FVector::ZeroVector, &FRotator::ZeroRotator);

The spawned actor already has a pitch value of -46 degrees, even though I spawned it with a zero rotator (not attaching it to any other actor). If I actually specify a rotator for SpawnActor(), t gives me even weirder values. Like, using

FRotator DirectionalLightSpawnRotation(100.f, 5.f, -30.f);

results in a rotation of (8, 82, 41) in the game. Also: the light has a scale of (2.5, 2.5, 2.5) when spawning, but I didn’t even specify a scale in SpawnActor().

I’m having these problems with ALL my actors, but some at least have the proper (1, 1, 1) scale. This even happens when I use the Spawn Actor From Class node in a blueprint, spawning a totally different class! Only when I drag&drop an actor into the level and specify the transform values manually, they are kept that way in PIE. So, is this a bug somehow nobody ever has stumbled upon, or what am I doing wrong / don’t understand here?

BTW, why is the order Pitch->Yaw->Roll in the C++ constructor, but Roll->Pitch->Yaw in the details panel? Always confuses me.

Thanks!

Found the reason why this happens. Some of the built-in actors have components with default rotation/scale. Because you can only see the root component transform in the actor’s details panel, when spawning an actor with (0,0,0) rotation that has its root component with (-46,0,0) as is the case with directional lights, you’ll still only see (-46,0,0) there, even if the actor itself has no rotation at all. So, one solution for this would be to change the component transform directly and keep the actor transform at default.

Exactly. Therefore it’s advisable to leave the root component’s scale at 1.0.

Curiously, many Unreal Engine sample projects don’t do that…