I did it! But i have some questions

So, i use this code:

FString ObjectName = GetOwner()->GetName();
FString ObjectPos = GetOwner() ->GetTargetLocation().ToString();
UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);

Question 1: The console neatly outputs x=… y=… z=… I honestly did not expect that. I assumed i would get an array of some sorts with the coordinates. How come that it automatically gets outputted like this?
Question 2: Say i do want an array of coordinates, how do i get that?
Question 3: In the course, Ben uses .Getlocation() , what is the difference with .GetTargetLocation()?

  1. Because that’s how it’s implemented
FORCEINLINE FString FVector::ToString() const
{
	return FString::Printf(TEXT("X=%3.3f Y=%3.3f Z=%3.3f"), X, Y, Z);
}

.2.

FVector Location = GetOwner()->GetActorLocation();
UE_LOG(LogTemp, Warning, TEXT("%f, %f, %f"), Location.X, Location.Y, Location.Z)

.3.
The optimal location to fire weapons at this actor

1 Like

Awesome, thank you! I am really impressed by the unreal libraries.

You could have also used
FString ObjectName = GetOwner()->GetName(); FString ObjectPos = GetOwner()->GetActorLocation().ToString(); UE_LOG(LogTemp, Warning, TEXT("%s is at %s"), *ObjectName, *ObjectPos);

Privacy & Terms