[PCG] Transform rotation only on the Z axis

Hi,

I am spawning actors (bp with mesh + light) along a Landscape spline using PCG.
So far so good, but i need to orient them to have them with a 0 Rotation along Z axis, but to keep the rotation on X and Y (because the meshes needs to be ortogonal to the landscape spline).

I’ve tried to use copy attributes to copy $Rotation.X and $Rotation.Y to temp variable and then, then RotZ to using absolute, then pasting back temp var to $Rotation.X and $Rotation.Y but this makes Unreal Engine instable and it crashes often when moving rescaling / translating the PCG volume.


In the screenshot above, connecting the last copy attribute node on the bottom right to the actor spawner makes unreal (5.3.1) crashes:

Assertion failed: IsRotationNormalized() [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Math\TransformVectorized.h] [Line: 1300]

There must be an easiest way or a way that works

2 Likes

Hi there! I have exactly the same problem. Any luck with this?

No, and I haven’t looked further to it, I was expecting an answer from the PCG community :slight_smile:

Yeah, so I’m in 5.3 and having the exact same problem, like i said. Unreal crashes instantly when i hit debug on anything following the Rotation tampering. I used Noise, with Set to 0, but alas, crashes.
I think there might be a way to do this using rotators in PCG, but i don’t know how to and resources are, of course, scarce on how to do that

You can’t just change the rotation because it’s stored in a transform. You need to create PCGBlueprintElement and change it inside.


This is what I used to generate stairs
image

1 Like

Thanks for your answer !

I tried your approach by:
Create a PCGBlueprintElement, and on that PCGBE I’ve overriden the point loop body

Then on my PCG blueprint, i’m calling that Blueprint :


but when I debug and inspect,
i can see points in
i do see nothing comes out

And even when I shortcut the PointLoop Body like below, I don’t get any point out:
image

Me Too
But I finded we need create “Execute with Context” function
image
This is my copy code successed

You can try try it

omg, there is a more easy solution. In projection node just remove checkbox from project rotation. Thats all.

2 Likes

Hi there!

I know this post is old now and lots of updates have since come out to PCG - but there is a very simple way of achieving this without creating a custom blueprint node.

Simply use an Abs node with the Input Source set to your chosen rotation axis (e.g. $Rotation.Roll) and then plug the result in to both the A and B inputs of a Subtract node with both inputs set to the same rotation axis.

Then, just keep using your points as regular from there.

The Abs node inverts any value below 0, meaning what you’re essentially doing is just subtracting the rotation by itself - thus, the result will always be, making your rotation absolute but only on your selected axis.

Hope this is useful for someone!

/Ehrix