Download

Going about rotating actors relatively around child component of another actor.

Hey guys,
I’m trying to do something basic.
I have put a more detailed explanation of it on the answerhub, but got no feedback as of yet. You can view it here:

https://answers.unrealengine.com/questions/384659/what-is-needed-to-convert-a-relative-rotation-to-a.html

The short of it is that I have a relative location of a child component of one actor, and I want to spawn several new actors around that child component, facing the same direction as the child component, but with a slight off set.

The most important part of this is that I need the identify the world rotation for these new actors. I know I could spawn them and then add a relative offset (addRelativeRotation), but due to some requirements I need the world rotation value before they are even spawned. This basically becomes converting a known relative location of one actor into world space, which for some reason is eluding me. I have all the data in the world, just not the knowledge of a function to use that data to get my desired results.

Would any one know of a good way to go about this?

You can get world rotation of component to set their direction. Their position is relative location of the child component + offset vector in local space, pull result into Transform node with child components parent transform as input.

Hello BoredEngineer,
Thanks for the response.
Could you possibly elaborate a bit more?

I got this done,
but the next part:

I do not quite fully understand which transform node you are referring to.
I do something like this all the time for adding a relative offset to a location using “Transform Location” node, but I am unable to find a node similar for rotation. I do have transform direction node that I think may be some what relevant but I am unsure of exactly how to use the vector pins along with the rotation values to get a relative rotation converted to a world rotation.

You don’t need transform for rotation. There is node GetComponentRotation, it will give you a rotation of a child which you can use to spawn other things.
It might be called GetWorldRotation, just drag pin from component itself.

Hello again BoredEngineer,
Perhaps I am having trouble understanding this, but how would getting the world rotation of the component help me here?
I want to add a relative offset to the component’s own relative rotation, ensuring that the new actors I am spawning share the same relative direction (but with the relative offset).

What I want would be similar to spawning the actor with the world rotation of the child component and then adding a relative offset (add Relative Rotation), but in reality I need the actual world rotation of that final rotation well before I spawn anything for very particular reasons. So basically I want to recreate the logic Add Relative Rotation would perform, with just getting the value instead of actually setting the rotation.

So what I have is something like this:

Relative Rotation of Child Component + offset (lets say 45 roll, so X+45,Y,Z), however once I have that value I simply cannot just spawn the actor in as it would be different depending on the world location of the parent component. I need to perform some sort of function to take that relative rotation and convert it to a world location.
Determining what that function is, and what values I would need to pass it is where I am stuck.

Please let me know if you believe I misunderstanding your explanation. I may not be the smartest programmer, but I am really set on getting this figured out.

Can you make a simple diagram? I’ve lost what are you trying to do.

Hey again BoredEngineer,
First I want to thank you for your assistance in this.

In the answerhub post I made here I have a good description along with some screen shots, including what I want the intended output to be. the post is here: What is needed to convert a relative rotation to a world rotation - UE4 AnswerHub

Basically the short of it is I have a relative rotation and I want to get a corresponding world rotation. UE4 does this a lot and there are plenty of nodes that can do the transform for me (add relative rotation), but I actually want the math formula as the value is actually what I really need.

There is node called Compose (if I remember correctly). What it does is combination of transforms, which allows to convert from child transform into parent transform or vice versa. You need to make a local transform for your cylinder - how they should be positioned in regards to the cone if cone would be in 0,0,0 location and without rotation. Then you need to get a world transform of cone component and Compose it with local transform of the cylinder, the output will be transform and it will give you both location and rotation of cylinder in world space. Order of input in Compose node matters and will produce different result if local transform is connected to top pin or bottom pin.

This is how it’s done:
ComposeTransform_BP.JPG

in this example, Cube1 is placed one meter in Z axis of cone and rotated by 45 degrees:
ComposeTransform_Render.JPG

Hey BoredEngineer,
That’s exactly what I was looking for, thank you very much.
Looking at the source it looks like its simply FTransform Delta * FTransform World. I’m wish I could say this made sense to me, but it looks like I need to read up on quaternions, specifically how the W variable (axis?) is used. It looks like that is the missing piece for my puzzle mentally; However for actual functionality you provided the perfect solution.
I want to thank you very much for your assistance, I owe you one4. If you want you can post the answer on the answerhub and I’ll mark it so you get credit for it.

You are welcome!

Ohh, right, you’ve posted it on AnswerHub too. I’ll add it there.