Download

How to set local location?

Hi! Can not solve this problem no matter what.
I have:

Actor1
–Actor2
hierarchy,

this:


	FVector CurrentLocation = actor2->GetActorLocation();
	CurrentLocation.Z += 10f;
	actor2->SetActorLocation(CurrentLocation);

will always get location of rootCOmponent (actor1), not actor2 (even though I run this function on actor2), and functions like GetActorLocalLocations are not present.

Which is the right way, say, increase Z location value of actor2 by 10, when it is child of actor1?

I’ve tried different variations of using GetTransform and stuff, but always ended up with mispalced results.

This should work (for Blueprint equivalent function see AddActorLocalOffset | Unreal Engine Documentation)


actor2->AddActorLocalOffset(FVector(0.0f, 0.0f, 10.0f), false, nullptr, ETeleportType::None);