# Multiple Objects Revolving Around A Rotating Actor

Good Day,

Currently I am creating an editing tool with which you can manipulate multiple objects using an actor which serves as a cursor or pivot point. At the moment it is possible to move, scale and rotate objects with this cursor actor.

Below is the code as well as a short GIF to demonstrate how it is setup at the moment:

As you can see the setup is almost complete however there’s an issue with the rotation. At the moment the rotation of the cursor will rotate the objects around themselves. Instead what I need is for the objects to actually revolve around the cursor and actually changing the positions of the objects rather than their rotation.

Question: How to rotate the objects around the cursor instead of themselves?

I hope I was clear enough. I’ve already searched for a few solutions but I must be doing something wrong since I get strange glitches and I didn’t manage to make the objects revolve around the cursor.

I’m happy for any kind of advice,

Have a nice day!

I assume that your pivot point is spawned with zero rotation. When it is spawned, you have to save the relative delta vector from the pivot point to each actor that needs to be transformed by it. Now when you rotate your pivot point, rotate the delta vectors too. Then the final location of each actor is the pivot point location + the rotated delta vector.

Thanks for your suggestion. Note that I need to implement this inside the code you can see above. Im’ not really sure what your are suggestion so let me explain a bit and maybe you can help a little better:

a) Just to be clear the ‘pivot point’ or ‘cursor’ is a Blueprint Actor inside the scene and while you move or rotate this actor, the objects need to adjust accordingly (which they do like shown in the gif above).

b) The input ‘Cursor To Instance Offset Vector’ is probably what you mean with the ‘relative delta vector from the pivot point to each actor’

c) When you say ‘when you rotate your pivot point, rotate the delta vector too’ then this is exactly what I’m asking: How do I do this? A small code example that fits into my code example would be very helpful

Thanks a lot for your advice, you are very much appreciated!

Since you already have the delta vectors, this small extension should work:

Solution with no code at all.

this is not helpful at all!

This is perfect! I was really overthinking this stuff and making it much more complicated than it would have been. This works like a charm, thanks a lot!

Now we know that you’re not

happy for any kind of advice

Maybe you can help me a little further, there was a small problem. I’ve tried to apply additional relative rotations to my objects, however the rotation is locked to one axis when I rotate.

Here’s a small gif that shows what I mean:

Obviously this is not working quite as intended. Instead of rotating the objects relative to the rotation around the cursor the rotation of the objects is locked towards one direction… this the code I use:

As you can see I have simply plugged in the rotation of the respective object into the final result of the Transform… The effect shown in the gif above seems to be logical but it’s not what I need.

I have tried to use ‘CombineRotators’ and other methods but this gave me at best some unwanted ‘spinning’ results… This is really a little beyond me so I’d appreciate your help very much.

I hope you can spare the time otherwise I’ll just try a little bit myself and if I still have no luck, I’ll probably need to make this a separate question…

Thanks a lot,

Kind Regards

I’m glad I can help. Normally I would have tried using CombineRotators, too, like this:

But since you said it doesn’t work, this version is more awkward but should be more stable:

Hi there, so I was testing it a little bit out and ‘CombineRotators’ seems to be the correct solution. The problem with the spinning thing has probably to do with my setup and how this works in the construction script…

Apparently, when I grab the rotation and start moving it, instead of combining the Rotators only once it seems to continuously add the respective value as long as I hold onto the rotation, which results in a spinning effect… Here’s a gif that shows this problem:

Maybe you know a solution to this problem as well?

Thanks again, you are really helpful!

I guess that you pass the current object rotations as ObjectRotation, but because the construction script is executed each frame you hold down the mouse button, the cursor actor rotation is constantly added (as you said). But why doesn’t the same thing happen to the offset vectors? Are they gathered in a different way? Perhaps you can apply the same way for setting the object rotations.

))) I know what is going on, but unfortunately you don’t want my advice)

@GullJemonStudios If you don’t mind I will post my comments in my useless downvoted answer)

Is this you are looking for?

@ Two-faced, If you have any valuable input, then I’ll gladly take your advice… I’m sorry you took it so personally, it wasn’t my intention to hurt your feelings. Your previous ‘solution’ wasn’t helpful because it didn’t seem to relate to my question and there wasn’t any explanation to it. If you know the answer to my problem then, by all means go ahead, everyone will thank your for it, including me!

@ Benergy, The data is gathered from the same source, I think the same doesn’t apply to the offset vectors because we are dealing with a Quaternion for the rotation, which is a little more complicated. However it must be possible somehow right? @ Two-faced, care to share your knowledge with us?

Oh god how do I love procedural generation!

Oh yeah, that’s the effect I’m looking for yes.

So is there a way to do this inside my code? Because I believe your are doing this with Static Mesh Components inside a blueprint and move the actor itself right? Maybe I’m wrong but in any case just to be specific:

In my setup I’m using a blueprint (A) with an instanced static mesh component and manipulate the instances using another blueprint (B) that serves as a cursor. The blueprint (A) containing the instanced static mesh component mustn’t move, only the cursor (B) does! As you can see this might not be as easy as in your example.

If you have a solution for my specific case, I would be very happy to hear how I need to modify my code above in order to make this work. Keep in mind that I need to have this for all the rotation axes not just one or two.

A blueprint rotator object is not a quaternion, but a struct of roll, pitch and yaw.

What I meant with the offset vector was this: When I assume that the offset vector is gathered with every call of the construction script, it would change every frame when you rotate the cursor actor (like the rotation currently does). But then you would rotate a vector that was already rotated last frame, so you would have the same spinning result for the location of the actors. But this was not the case in your last gif, so I assumed that you gather the offset vectors differently than the “offset” rotation.

UPDATE: After a bit of time I think I could pin point the problem and found a workaround as well.

1. I think the reason why this doesn’t work properly with the rotation is probably to blame on how UE4 is utilizing their rotation tool inside the editor (at least I think that’s the problem) Somehow when moving the rotation tool and using a ‘CombineRotator’ node, when feeding through the construction script, the engine will constantly and exponentially add more rotation to the instances instead of just once per setting. As of now I’ve not been able to find a Solution to this problem…

2. The workaround is simple: Instead of using the built in rotation tool of the editor I’ve created a rotation variable and made it public. Instead of using the cursor, now you have to use the variable inside the details panel, which is sadly a lot more inconvenient. Despite working correctly the rotation still behaves very strangely while adjusting (exponential increase of rotation speed depending on value). You must also change the additional rotation settings back to zero if you intend to move the rotated objects again, if you don’t do that everything gets messed up!

In due time I will file a full report of this behavior and issue a Feature Request, would be immensely practical if this detail could be fixed or if there’s a way to device some better workaround than the one stated above.

@ Benergy, Thanks again for your help!