So for example, actor red is at 1,1 in world location and actor green is in 3,3 in world location.
Is there a method to get the location of actor red relative to actor green, just like in this graph, where actor red’s relative location is -2,-2 wrt actor green.
can you tell us how your actors are managed? Are these different actors/meshes in ONE blueprint or are these also different blueprints.
Case 1 : You can use SetRelativeLocation. These will set the relative location of one component relative to its parent
Case 2: You will have to get the location of your e.g. GreenActor. Then GetLocation of this actor, add your desired RelativeLocation and plug this in as the destination of SetWorldLocation for e.g. your RedActor
And for your relative location: When you use VectorA-VectorB A will be the one which you want to move relative to B.
Could you explain a bit further please. Basically, I want to be able to SET a new relative location wrt. to the other actor. So if X world location of actor 1 is 10, and X world location of actor 2 is 20, then X relative location of actor 1 wrt. actor 2 would be -10, since actor 2 is set as origin.
So if I wanted to set the X relative location of actor 1 wrt. actor 2 as +10, aka in the world, it would become X = 30
How would I go about doing that? I hope I was able to explain my issue.
Get the actor from the class you want with getworld into your main actor class and then set relative location to main actor to the component you got from the other class with get world.
They are all subclassing so you can do that.
That way you can attach as many actor components from other classes into the class that you want to be the root component of all the components from other classes.