SetActorLocation or SetWorldLocation or WorldRotation?

Hi!

Reading the documentation about these functions I have found something that I don’t understand.

In the SetActorLocation, the explanation for NewLocation is: The new location to move the Actor to. And, in SetWorldLocation is: New location in world space for the component.

For the SetActorRotation, the explanation for NewRotation is: The new rotation for the Actor. And, in SetWorldRotation is: New rotation in world space for the component.

I don’t understand “world space”. I suppose than in both cases the actor is inside the world and the location and rotation is inside the world space.

Which are the differences between SetActor… and SetWorld…?

I have tried the same code changing SetActorRotation with SetWorldRotation and I can’t see any difference.

Thanks.

1 Like

As you can understand from its name, “SetActorLocation” works on Actors.
image

SetWorldLocation / SetRelativeLocation are used to move scene components (like meshes, lights, empty scenes, et cetera)

You can see the target type by hovering the target pin:

2 Likes

@Ares9323 Thanks, but I can’t see any difference.

To move where, to move them inside the actor. Does the actor location remains the same but you move a mesh from it?

I’ve been learning UE4 for a year now and this one had me confused for some time as well. But it is as simple as @Ares9323 said. To give an example, on the default Third/FirstPersonCharacter, add a component (such as Arrow etc).

You cannot call GetActorLocation on the component. You will have to get its location in world space. The reason is simply because it is not an actor. If you try to call GetWorldLocation on an Actor for example, it will make you select a component of it, such as the Mesh.

Of course there is a lot of technical logic going behind this but this is as simple as someone can tell you! :grin:

2 Likes

@isikdev Thanks.

What is the point of moving a component that is inside an actor if moving the actor also moves this component?

Example, Actor made of two cubes placed at 500,500,100

Now we are going to Apply every function and set the same new location to 0,0,500:

First case: SetWorldLocation applied to the red cube:


The actor remains where it was but the red cube is moved at world coordinates 0,0,500

Second Case: SetRelativeLocation applied to the red cube:


The cube is moved in the z at 500cm from the actor centre, in this case its world coordinate is 500,500,600 (500+100 of the original position)

Third case: SetActorLocation applied to the actor (because you can’t apply it to a component):

4 Likes

The point is that you don’t always want to move the whole actor, but only its parts as you can see in this door for example.

I hope my explanation was clear, if it was please mark it as the answer, otherwise feel free to keep asking