Rotating a group of actors around a central point

I have BuildParts a bit like rust. I load them all in as individual actors, so they are unrelated actors, and it seems I can’t “Group” them the way that the editor does.
I want my building to start with a random rotation after it’s loaded from file. I did this the unthinking way, and it was hilarious as you would expect, all objects rotated around their own pivot points.
I can use Get Actor Array Bounds to find the ‘centre’, but for all those buildparts to rotate around the centre I need to translate as well as rotate. Back in c++ I used to try and nut these thing out with matrix multiplications and trig. Is there an easier way in Unreal to treat a bunch of individual actors as a group?

1 Like

You can attach them to a central point, and rotate that.

Or, if you want to calculate it, you can take a vector from the central point, and use ‘rotate vector about axis’.

3 Likes

Kind thanks! I found the API’s for attaching actors to actors and thanks again for the second option, that might be better for a building where the parts can be removed\destroyed to zero (where I would have to collapse away the root actor). Awesome answer!

1 Like

If you have a lot of attachments, things can get slow. If that happens, turn off the collision during the turn :slight_smile:

1 Like

This seems to be working for a static 30deg rotation. I can add RNG next. Very appreciative that you responded so quickly. Thankyou again. … and yes I’ll leave a comment in there to disable collisions if this ever gets slow. It’ll probably only be a load time routine.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.