Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

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:

alt text

alt text

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!

Product Version: UE 4.15
basesetup.png (138.8 kB)
cursordemo.gif (3.1 MB)
more ▼

asked Apr 30 '17 at 11:26 AM in Blueprint Scripting

avatar image

133 31 30 34

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

2 answers: sort voted first

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.

more ▼

answered Apr 30 '17 at 01:45 PM

avatar image

831 21 4 29

avatar image GullJemonStudios Apr 30 '17 at 03:04 PM

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!

avatar image Benergy Apr 30 '17 at 04:44 PM

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

screenshot.png (75.6 kB)
avatar image GullJemonStudios Apr 30 '17 at 05:17 PM

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!

avatar image GullJemonStudios May 01 '17 at 03:11 PM

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:

alt text

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:

alt text

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

demogif.gif (2.2 MB)
avatar image Benergy May 01 '17 at 03:37 PM

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

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

screenshot1.png (101.7 kB)
screenshot2.png (138.4 kB)
avatar image GullJemonStudios May 02 '17 at 08:58 AM

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:

alt text

Maybe you know a solution to this problem as well?

Thanks again, you are really helpful!

spinning.gif (5.1 MB)
avatar image Benergy May 02 '17 at 09:44 AM

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.

avatar image GullJemonStudios May 02 '17 at 12:17 PM

@ 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?

avatar image Benergy May 03 '17 at 06:35 AM

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.

avatar image Two-faced May 02 '17 at 09:59 AM

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

avatar image GullJemonStudios May 02 '17 at 12:11 PM

@ 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!

avatar image GullJemonStudios May 03 '17 at 10:50 PM

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!

avatar image Benergy May 04 '17 at 10:11 AM

If you like, you can share a screenshot of how your CursorObjectDistances and ObjectRotations are gathered in the construction script, perhaps we can find a way to get it to work as you intended it at first. But that's only a offer, no need to do so if can live with the workaround you've described :)

avatar image GullJemonStudios May 05 '17 at 01:29 PM

Thanks a lot for your offer. Yes to be honest, your help would be very much appreciated.. my workaround isn't really that great.

avatar image Benergy May 05 '17 at 03:16 PM

I tried to download the project but it seems you havn't made it public.

avatar image GullJemonStudios May 05 '17 at 05:54 PM
avatar image Benergy May 06 '17 at 03:35 PM

Okay, now I was able to take a look into it, but unfortunately the construction script is only executed when the rotation was changed (i.e. I moved the mouse) but not when I just hold down the mouse button. I used 4.15.2 built from source.

But about the rotation problem, it's the way you have already written it: Because you feed the combination of current rotation and cursor rotation into the TransformArray, which is used as current rotation in the next execution, the cursor rotation is constantly added to the object rotation. And this is new for me: This doesn't happen with the offset vectors because you create them in the construction script of the MeshEditor and don't change them in the cursor construction script.

So my suggestion would be following: Instead of using "Add Instance World Space" use "Add Instance" at the end of Stream Edit Mode. For this you have to keep all transforms local which is a lot of easier in the end. Then you can copy the cursor's rotation to the MeshEditor rotation and keep a local rotation for the mesh instances, which is automatically added to the world rotation of the MeshEditor.

avatar image GullJemonStudios May 06 '17 at 06:26 PM

Hey thanks for taking a look. It's really helpful to get some insight from someone else! So about your suggestion:

Then you can copy the cursor's rotation to the MeshEditor rotation and keep a local rotation for the mesh instances, which is automatically added to the world rotation of the MeshEditor.

If I understand you correctly you're idea is to just rotate the MeshEditor actor and this would be literally the only possible way right? In this case I have no choice and must use a combination of both my workaround and your suggestion for my system to work properly.

Thanks again! Now I can relaxe and continue with this project as planned. I'll give you a note once I'm done, but it might yet take a few months until we're there.

Kind Regards,

Gull Jemon Studios

avatar image GullJemonStudios Jul 21 '17 at 10:04 AM

Just recently I found the perfect solution! Instead of rotating everything using the distance vectors from the objects to the cursor, we rather calculate the distance vectors to the center point for example and rotate this around the cursor instead. I'll update my answer here with a complete walkthrough as soon as I've got time..

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

Solution with no code at all.

alt text

more ▼

answered Apr 30 '17 at 04:52 PM

avatar image

842 31 13 47

avatar image GullJemonStudios Apr 30 '17 at 05:11 PM

this is not helpful at all!

avatar image Two-faced Apr 30 '17 at 05:21 PM

Now we know that you're not

happy for any kind of advice

avatar image Two-faced May 02 '17 at 12:38 PM

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

Is this you are looking for?

alt text

avatar image Two-faced May 02 '17 at 01:41 PM

Oh god how do I love procedural generation!

alt text

alt text

avatar image GullJemonStudios May 02 '17 at 06:07 PM

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.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question