UProperty TArray of AActors alwys have the Num() of 0 even when the array is filled and i access the elements inside. What am i missing?

Hi, im new to Unreal (5) and i have the Problem that a UProperty TArray that is filled, always shows me 0 when calling the Num() Function. I Set the Values in the Editor, via the Component Window.

in h File:
UPROPERTY(EditAnywhere) TArray<AActor*> Cameras;

in cpp File:

void ACameraDirector::BeginPlay()
{
	Super::BeginPlay();
	GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, FString::Printf(TEXT("%f"), Cameras.Num()));
	GEngine->AddOnScreenDebugMessage(-1, 5, FColor::Red, (Cameras[1]->GetName()));
	}

The First Output is “0”, the Second Shows me “CameraActor1”

Some Debugger Picture

Hey @Strieglitz. The truth is everything looks fine, the issue might be in the print itself. Try changing the format specifier from %f to %i for integer, or even to %s for string and cast that integer to string.

Hope this helps

1 Like

:man_facepalming: â– â– â– â–  thats right

thank you very much for helping me :slightly_smiling_face:

2 Likes