# How's Add Actor Local Offset calculated?

I would like to know how the node ‘add actor local offset’ calculates the new location while it keeps the rotation of the actor.

It move the actor by an amount relative to where it already is, without changing the rotation.

It moves it in it’s local reference frame. Meaning that if you add local offset in the x-direction, it will move in the direction the actor currently points with it’s x-axis.

but how do I calculate the new position of Actor B if Actor B location is relative to Actor A? if Actor A rotation is 0 and I add 500 on the X-axis of Actor B, Actor B will be place a the correct location, but if Actor A has a rotation, it won’t keep the relative offset.

Can you give a specific example with a picture?

Sure!
In both examples, I’m using the same offset. The only variable that change is the rotation of Actor A. I’m trying to snap the two floors together.

Here :

](filedata/fetch?id=1788246&d=1594756321) Here the snapping is ok, but actor A doesn’t have any rotation(0,0,0). (actor B is the green one)

](filedata/fetch?id=1788247&d=1594756375) Here I rotated actor A and actor B doesn’t snap the way I want.

this is when I use ‘addactorlocaloffset’ and actor A and I rotated it. This is the behaviour I would like to achieve.

I’m pretty sure Actor B’s location is relative to the rotation of actor A, but I’m unsure how to calculate the location.

As long as you’re not attaching them to each other they should behave as independent actors.

What’s your code for snapping B to A?

No, they are independent of each other, it is a modular building system, similar to Ark or Rust. The code isn’t complicated, I simply get the transform of Actor A, then spawn actor B at the same transform of actor A and then use ‘add actor local offset’ to ‘snap’ actor B to actor A.

I’m working on a multiplayer project and basically I’m trying to make a collision check before I spawn the actor. I want to use a box trace that will look if the box trace is colliding with any other actor…

I did this:

It works fine. What does your code do?

Yeah, this works fine indeed.

Although, I would need to manually add the local offset. how can I do the exact same calculation than ‘add actor local offset’ but without any actor? I just need to know the transform.

Well you need to know which side you’re connecting to, and then use either GetActorForwardVector or GetActorRightVector multiplied by the amount you want to shift.

It’s easier if instead of actors, they were blueprints, then you can put connector points on the sides and you don’t have to figure anything out. Just move the actor to where the connector point is.

The best way to do things like this might be to snap sockets together. I made something like this here https://forums.unrealengine.com/deve…-align-sockets. But in your case you could delete the AttachToComponent node.