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.
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 ).
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.
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.
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.
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
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?