Setting rotation for an actor when it has been rotated

Hi guys:

I was wondering that how to calculations the rotation values when the actor has been rotated once.

I want to set Y rotation to the actor when it has been rotated once, but I don’t know how to calculations the values.

Here is a screenshot of my question.

Thank you very much if anyone can tell me how to calculations and get the value in blueprint.

I guess you’re referring to the fact that it’s not clear what’s happening with rotation once the object is no longer world aligned?

You can just used AddWorldRotation, that way you don’t need to know about the axis.

In a more general sense you’ll need a combination of GetActorRotaton and SetActorRotation.

Hi ClockworkOcean:

Thank you for the reply.

Actually I want to control the DirectionalLight rotation in the world and have tilt.
I’ve already done the bp script and used “SetActorRotation” for controlling the sun light by slider bar.
However I want to make the sunlight have angle and tilt.

To using “SetActorRotation” needs to have a precise parameters.

I’ve been tried that AddWorldRotation to the Actor may make the result doing right. But AddWorldRotation cannot using the precise parameters to control it. That is why I need to know how to calculations of it.

Any comments and suggestion will be appreciated.
Thank you.

Here is my screenshot.

Ahh, I see what you mean, let me think a bit…

Yes, you just need to do a GetActorRotation first. Split the output pins and feed the X and Z into you new rotation ( SetActorRotation ), but only set the Y. ( This is in the case of setting Y, you need to do the same for the other two axis ).

Do you get what I mean?

Hi ClockworkOcean:

Thank you for your reply and patient. ^ ^

That will be great if had a answer.

Try working in local space instead of world space. If the light is pointing in a random direction (in your example, yawed 45 degrees) and you have also applied some tilt (downward pitch) to it, then trying to manipulate the light still using world axis rotations will definitely cause all three values to change. Using some trig, you mathematically could calculate the correct values to use to get the behavior you want in world space - but, you’ll find it much cleaner to use an AddLocalRotation node (if the object is a component of your BP) or an AddActorLocalRotation node (if the object is another actor but is referenced by your BP) instead. This way, if you want to add 10 degrees in pitch you can feed it a rotator of [0,10,0] and it will pitch down by 10 no matter what the light’s current orientation is. And you dont have to do the stupid math. This should fix your problem easily. It may be worth noting that another common thing you could try is to rotate things around vectors … I think of it as asking “where would I put a handle to twist in the direction I want?” If you wanted to look left or right, the handle would sit on your head pointing upwards. So a rotation around an object’s Up Vector will affect its yaw. If you wanted to look up or down, the handle would point out the right side of your face. Therefore, a rotation around an object’s Right Vector affects only the pitch [this is what you are trying to do]. Finally, a handle going forward out your face would create roll, around the Forward Vector. Hope that helps a bit.

The answer is below…

Thank you… guys. :slight_smile:

Hi 1l2Hawk:

Thank you so much for spend time to reply my question.
I’ve already figure out that using ‘AddActorLocalRotation’ will get the right result for me.
But thing is ‘AddActorRotation’ can’t be used by slider bar because what if I using slider bar to manipulate the the sun direction, and I must do a calculations to have a precise parameters to feed the rotation node, otherwise ‘AddActorRotation’ only ‘add’ values and never can be controlled. That is why I am looking for the math arithmetic to fix this problem.

I knew it because I tried before in other case.
For example:
Let’s try for an one axis maybe X, and we set the current degree is 10, then I want to plus it to 15 and single step is 2.5, so we make AddActorRotation [2.5,0,0] for 2 times to get the right result.
But how could we using the slider bar to feed the value into AddActorRotation? An ‘AddActorRotation’ will continuing plus and will never get the right result, that is why I need to feed the precise parameters for it.

Any ideas? Or please let me know that I was wrong of it.

Thank you guys.

I can tell all of you that NONE of this stuff works, because of gimbal lock when the sun hits midday. Looking for a solution…

Edit: found it, see above…

This isn’t so much a problem with rotating an alerady rotated actor, it’s more to do with the sun in UE behaving a weird way. Answer here, begin play:

This is now to increment Y ( I just did it with the keyboard ):

and, obviously to decrement Y:

It’s exactly the same for Z, I’ve attached a text file with the whole BP.

[link text][4]

This also works really nicely with your sliders, having a max and min built in.


hey there.
what you can do is : create 2 rotators variable (one for max value, and one for min value. and lerp them using the slider as alpha.
plug the lerp output in a setactor rotation and it should work

hey there
i m not sure i totaly understand what you want to achieve :
is that it ?


Hi ClockworkOcean:

Thank you so much for your reply.
I was in the weekend till now I saw the message and sorry for late to reply to you.
Now I am going to test the BP Script, will going back to tell you the result. ^ ^

Thank you again for the answer.

Hi ClockworkOcean:

Thank you for the awesome demo. I test it well. But I am sorry that was not a result that I expect to.

So I make a movie clip for you. Hope this could make my point clear…

Thank you…


Hi expose:

Here is a movieclip that I made.

This is what I want to do.

Thank you for the comment.

Hi Akio

I’m afraid you can’t make an orbit movement with the UE directional light. It doesn’t make any difference where you place it in the level. The only thing you can do is change the Y and Z rotation, which the BP does.

Is there something else I’m missing? Do you want to simulate orbit by manipulating the YZ?

so with your sun rotating, did you try a look at node, so your light always point toward the center of the scene, it may do the trick?

Hi ClockworkOcean:

I’m sorry I was in a hurry to go out.
So I quick to make the step photos.
Will back as soon as possible.

Please let me know if you don’t understand.

Thank you for your time…