Rotate yaw actor according to a base rotator

Hi everybody!

I have an object which follows my cursor for placement purpose. This object can be placed on a sphere! It follows the sphere too, according to the center.
But, when I click, I would like to rotate my object before placement (a yaw local rotation). I don’t understand how to do that. I tried a lot of things! I can get the mouse location to create an angle calculation, I can use “find look at” to get a directional rotator to rotate my object…etc. But I don’t get anything working with the “base” rotation (according to the sphere)…

The node “set local rotation” would be great x)

Here is a sketch to understand what I’m looking for:

Thank you very much for help!
Kiss <3

Have you tried Set Relative Rotation and Location or Add Relative Rotation or Add Local Rotation ?

Hi @Flash7 thank you for your answer!
I tried all three! Add Local Rotation is the best way, but I don’t succeed to set the object in front of my mouse because my node is under tick event… So, it add every time and the object rotate alone…
I surely can do it with, but I don’t know how :confused:

EDIT: I can check vector alignement between the object forward vector and the find look at cursor forward vector, then add local rotation with it. But the object follow the cursor only on around 180°, because the alignement is the same when the mouse is behind the forward vector too… :confused:

why don’t you use a flag if to rotate or not? like a boolean variable that you set when you click.

Hi @Flash7 !
I already have a boolean branch before add local rotation. But I need to use every tick during left button is pressed (until is released).

I found this semi-issue with vectors like I said in my last comment (under edit):

On this blueprint, “set cursor terrain position” is from my library, it found the cursor location on the sphere under the mouse.
The find look is the vector from the mouse.
The forward vector (from self = from the object), is the front of the object.
When my mouse is left from the object, the result is negative (remove local rotation) and the opposite for the right (add local rotation).
This works on 180°, but no more. Because there are 2 alignements with the forward vector of the object (in front, and in back) :confused:
At the backward, the reaction is inverted, but the object keep in the first 180°. Never go back.

EDIT: I replace the vector length by an addition of split X, Y, and Z, before multiply. Same problem, but better precision. (With the vector length, the object can turn in only direction).

But I need to use every tick during left button is pressed (until is released).
when you pressed a button - set variable, when you release - reset it.

I still can’t fully understand what it going on, can you make a video?

Also, I noticed that when you add delta rotation, you do not multiply to delta time. You need it to make your rotation frame independent.

Hi @Flash7 !
Yes, I already put a boolean before my blueprint above, no problem with this :wink:
I recorded a little video to show you what the code above do exactly (without the delta time, good point, I will add it later!).

Here is the video:
The rotation is approximately good, but impossible to go around at 360° :confused:

Yes that’s it!
I place a pyramide on the surface of a sphere to be precise :wink:

ok, do I get it right: you first place a sphere on a surface, and then you rotate it, right? And you rotate it basically like this: you click left mouse button and while the button is pressed you rotate where the cursor is. Is it how it should work?

ok, to do that you need to do a line trace to the surface every tick. You find intersection point with a surface. Then you need to call Find Look At - that will give you a rotator that will tell you how to turn your pyramid to face that location. You need to set rotation of your pyramid to that rotator. To make it as a smooth rotation - you set rotation by using interpolation RIterp To.

I already have a line trace in my “Set Cursor terrain position” which is under my cursor, but I need to get the impact point and not the location, true?
For the “Find Look At”, I need to set it between my pyramide location (start) and the line trace (target)?
Like this, it doesn’t work :confused:

for line trace impact point and location will be the same. For the “Find Look At” start would be pyramid location, end - line trace intersection location. It should work. How do you apply that rotation to pyramid?

Hi @Flash7 !
Ok, That’s what I did. This issue works on a landscape or a plane surface, but we are on a sphere (this is the big problem ah ah). I need another “Look At” (in addition to the other) to put the bottom of the pyramid in direction of the center of the sphere. If not, the pyramid rotate well on top on the sphere, but bad on sides, and upside down on bot.

why don’t you intersect with a plane then? You know your pyramid location, and normal, so you use this function: Line Plane Intersection (Origin & Normal) | Unreal Engine Documentation

Hi @Flash7!
I tried some things with the Line Plane Intersection, but without any success… Can you provide me a more detailed example?

It is probably you did not supply correct data to the function. Look, you have your pyramid. It has a location in the world. Then you need to rotate it where the mouse cursor is, right? As you could see, you cannot get a point where to rotate to by using a mouse intersection with a geometry under cursor - it will be all screwed up. So, you need to use an imaginary flat surface (plane) where the pyramid sits on top of it. Now, imagine you have that surface. All you need to do is to find a location where mouse cursor intersects with that imaginary surface. To do that you need a ray that will intersect with the surface. Hoe to get that ray? Use function Convert Mouse Location To World Space (use target as Get Player Controller). This function will give you line start and direction.

So, parameters for Line Plane Intersection (Origin & Normal):
Line start - location from Convert Mouse Location To World Space
Line End - location + direction*10000 from Convert Mouse Location To World Space
Plane Origin - Pyramid location
Plane Normal - plane’s orientation → normal to your surface; assuming that your Z is pointing up → (0, 0, 1)

You can always use debug draw plane to visualize it.

I skimmed the above without reading it thoroughly; I looked at the sketch, though.

If this is something that you’re trying to achieve:

Then consider adapting the following to your needs:

In the level blueprint:

In the cube:

Thank your for these precisions!

But, always the same problem with another try from last days : the pyramid ignore the sphere.
Maybe I did a mistake on your blueprint…

hm… not sure what surface location and normal at is returning. Make it simple first. Make normal as a normal to your world surface. Also, you can always place draw debug sphere to see locations you are hitting, etc. to help you to visualize what you are doing. If you don’t know how to use Draw Debug Plane, you can use Draw Debug Axis with that normal to see how your plane is oriented (XY, Z - up).

Hi @Everynone! Thank you for your help!
With your example, I better understand the normal hit, and I can align my pyramid to the surface under my cursor. But the relative rotation is utopic in my case, and this is the black point where I don’t know what to do :confused: