Breaking PCG vector parameter (or attribute)

Hi there! In PCG, I need to random rotate the mesh of 90, 180 or 270, so I’ve prepared a float array with those values. My problem is that the rotation is a vector and I want only to rotate on the z axis.
I’ve prepared this construction script:

But the node “Get actor property” won’t accept it, it seems to accept just floats.
How can i break the vector for just feed Z axis? Any suggestion?

Thank you!

#PCG

1 Like

Hi there @AFedeleallalinea11,

Hope you’re well!

This topic has been moved from International to Programming & Scripting: Blueprint.

When posting, please review the categories to ensure your topic is posted in the most relevant space.

Thanks and happy developing! :slight_smile:

Hi! Thank you for the advice, actually I’m always not sure where to post my requests, now I know it! Thanks again

1 Like

Hi! I’ve happened to bump into the same question you have, have you solved this yet?

1 Like

In PCG Graph, create a vector attribute (e.g. [1,0,0] to get X value) and dot product the two vectors.

Hello! The answer is to use the copy attribute node. For example, if you want the Z Rotation to be (0, 0, 90), but it is currently (15, 65, 20) you can create a rotator attribute (or take one from an existing node) with the values (0, 0, 90) and drop a copy attribute node with an input source of $Rotation and an output target of @Source. This will set the rotation of your target to (0, 0, 90).

Alternatively, you can mix and match rotations this way. For example, say you want something to always point towards the ground as to respect gravity. You can do all the initial rotation randomizations as normal, then drop a Transform Points node and check on Absolut Rotation. This will make the asset(s) have a rotation of (0, 0, 0) or whatever you set the absolute rotation to. Once this is done, you can use a Copy Attributes node, the source being the node before your absolute rotation and the target being the transform points node and set the Input Source to $Rotation.Yaw and the output target to @Source. And boom! Things will always point towards the ground but also respect the Z rotation of the assets so they don’t behave like billboards.