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:
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.