[BUG] Get Actor Location fails for Child Actors

Hello!

In 4.7.2, and presumably in previous versions you cannot get location of an actor that is used by a Child Actor Component, it will always return a zero vector. I assume this is something to do with inline function using root component location, but child actors doing something funky with root component?

Thanks,

Luke

Hi ,

I’m not certain I understand. Is Get World Location for ChildActor component returning a zero vector? This works for me:

34859-childactorgetworldlocation.png

I tried that with Child Actor as root component as well as a sub to a Scene component. Are you setting this up differently? I checked this in 4.7.3, but I don’t recall having an issue with it in 4.7.2 either.

My code used to check it looks like this:

		for (TActorIterator<AScrollingPlayerStart> It(World); It; ++It)
		{
			AScrollingPlayerStart* Start = *It;

			FVector LOC;
			LOC = Start->GetActorLocation();

My setup is simple - I have a camera actor with a child actor component, and Scrolling Player Start is child actor. I noticed that actor I was trying to spawn was being spawned at origin, every time without fail - so I added that line to check location. In editor, I could see child actor where I expected it, but actor supposedly spawned at it’s location was at origin.

Whilst debugging, LOC always gets a zero vector - it finds child actor just fine, but fails to get location every time.

I tracked down cause of behaviour - a natively created subclass of actor does not have a scene component by default, whereas a blueprint created one does. Since it didn’t have a scene component, it could not correctly get location of actor.

I do feel this is a bit inconsistent though. It doesn’t feel right that a native version of a subclass should behave differently to a blueprint created one.

Hey -

Are you referring to location of child component in world space or location relative to parent location?

I created a child actor component and then use:

FVector ComponentLocation = ChildComponent->GetComponentLocation();

I was then able to print to screen x, y, and z value of vector to show world location of component.

Cheers

Hi ,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.