x

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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

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: alt text

Thank you very much for help! Kiss <3

Product Version: UE 4.17
Tags:
more ▼

asked Oct 28 '17 at 05:56 PM in Blueprint Scripting

avatar image

Goetheus
12 3 8 8

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

2 answers: sort voted first

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

more ▼

answered Oct 29 '17 at 03:53 AM

avatar image

Flash7
839 9 17 29

avatar image Goetheus Oct 29 '17 at 09:07 AM

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 :/

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... :/

avatar image Flash7 Oct 29 '17 at 02:34 PM

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

avatar image Goetheus Oct 30 '17 at 08:44 AM

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): alt text

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) :/ 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).

avatar image Flash7 Oct 30 '17 at 06:50 PM

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.
avatar image Goetheus Oct 31 '17 at 10:00 AM

Hi @Flash7 ! Yes, I already put a boolean before my blueprint above, no problem with this ;) 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: https://puu.sh/ybpTG/81b65da5de.mp4 The rotation is approximately good, but impossible to go around at 360° :/

avatar image Flash7 Oct 31 '17 at 01:36 PM

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?

avatar image Goetheus Oct 31 '17 at 01:41 PM

Yes that's it! I place a pyramide on the surface of a sphere to be precise ;)

avatar image Flash7 Oct 31 '17 at 01:49 PM

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.

avatar image Goetheus Oct 31 '17 at 02:45 PM

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 :/

avatar image Flash7 Nov 01 '17 at 03:04 AM

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?

avatar image Goetheus Nov 01 '17 at 08:22 AM

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.

avatar image Flash7 Nov 01 '17 at 01:04 PM

why don't you intersect with a plane then? You know your pyramid location, and normal, so you use this function: https://docs.unrealengine.com/latest/INT/BlueprintAPI/Math/Intersection/LinePlaneIntersection_Origin_Nor-/index.html

avatar image Goetheus Nov 02 '17 at 02:05 PM

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

avatar image Flash7 Nov 02 '17 at 02:28 PM

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.

avatar image Goetheus Nov 02 '17 at 03:29 PM

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

alt text

avatar image Flash7 Nov 02 '17 at 03:47 PM

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

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

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

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

https://gyazo.com/94d4cbb5f438668873e0184b9c22f44d

Then consider adapting the following to your needs:

In the level blueprint: alt text

In the cube: alt text

graph.png (209.8 kB)
cube.png (160.1 kB)
more ▼

answered Nov 02 '17 at 02:54 PM

avatar image

Everynone
14.6k 76 25 61

avatar image Goetheus Nov 02 '17 at 03:56 PM

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 :/

avatar image Everynone Nov 02 '17 at 04:05 PM

In the attached video I rotate the cube with my mouse wheel. It seems to be doing exactly what you depicted in the sketch.

What's stopping you from adjusting the axis value in the CombineRotators node in the 2nd screenshot I posted?

avatar image Goetheus Nov 02 '17 at 04:11 PM

Because the pyramide (or the cube in your video) must follow the cursor. My pyramide is already well placed when I click. It is attached to the surface of the sphere, and I can move my mouse without displace it anymore. But impossible to align the front of the pyramide with my cursor, while maintaining the position according to the sphere :/

avatar image Everynone Nov 02 '17 at 04:26 PM

Because the pyramide (or the cube in your video) must follow the cursor.

It is following the cursor. You want it to sit on the surface of the sphere, right?

It is attached to the surface of the sphere, and I can move my mouse without displace it anymore.

Stop updating its location in Tick. It will stay in place.

But impossible to align the front of the pyramide with my cursor, while maintaining the position according to the sphere

Attach the pyramid to the sphere, it will become its child and move with it.

From what I gather, you want to attach the pyramid to the sphere, rotate it and then be able to just move the sphere while the pyramid stays attached to the sphere. Please do correct me if I misunderstood you.

avatar image Goetheus Nov 02 '17 at 04:35 PM

I have 2 steps :

1/ I click on a button to get a pyramid. This pyramid follow my cursor, and is placed on the surface according to center of the sphere. I can place my pyramide where I want.

2/ I click to place my pyramid. It keep its rotation from before, and it is well placed on the surface. Nothing more is updated every tick. So far, so good. I don't release my click, and I can move my mouse without the pyramide follow it. But now I need my pyramid front watching to my mouse.

My English level does not allow me to express myself more clearly x)

Here is a video of one of my test (with a 2tan cacul for a virtual circle around pyramid... but no success) : https://puu.sh/ybpTG/81b65da5de.mp4

avatar image Everynone Nov 02 '17 at 04:56 PM

To rotate it toward the cursor, you can use Find Look at Rotation node. If you want to have it flipped on the side, combine rotators again.

alt text

https://i.gyazo.com/3ac4e58bb9b27c773f8c1b1eddf7565d.mp4

capture.png (353.2 kB)
avatar image Goetheus Nov 02 '17 at 05:03 PM

Yes, this is the first thing I did. But this only work at the top of the sphere. If I put my pyramid at the bottom, for example, the base of the pyramide is on the surface, and the head is in the sphere... The pyramid ignore the previous rotation and keep the X, Y, Z basic plan.

EDIT : I saw your video after my answer to your post! Your cube is out of the sphere. What I was looking for is rotate localy the pyramid, always on the sphere, and according to the center of the sphere (+ according to mouse location), exactly lik in my video (the surface is a sphere!).

avatar image Everynone Nov 07 '17 at 09:17 AM

You should then look into InverseTransform[rot/dir] nodes, it will allow you to create a rotation in relative space.

(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