Cast to other Characters

My bad you need an array of AActor.

TArray EnemyChar;
UGameplayStatics::GetAllActorsOfClass(GetWorld(), AEnemyCharacter::StaticClass(), EnemyChar);

From the array you’ll need to cast to AEnemyCharacter so you can get the health

ok. compile without fail. Its big progress!!
How i cant cast to array? please write.

i try

AEnemyCharacter* EnemyChar2 = Cast<AEnemyCharacter>(&EnemyChar);

but failed…need may be from to…or get

Enemychar is an array so you need to get 1 thing out of the array before casting. Cast enemychar[0] and it should work

THANK YOU!!! Its was hard way to sucsess))
Final code:

void UMyUserWidget::StartText()
{
	AMainCharacter* MainChar = Cast<AMainCharacter>(UGameplayStatics::GetPlayerCharacter(GetWorld(),0));
	if (MainChar)
	{
		Main = MainChar->MainCharHealth;
	}
	else
	{
		GLog->Log("MainChar:Null");
	
	}
	
	TArray<AActor*> FoundEnemy;
	UGameplayStatics::GetAllActorsOfClass(GetWorld(), AEnemyCharacter::StaticClass(), FoundEnemy);
	AEnemyCharacter* EnemyChar2 = Cast<AEnemyCharacter>(FoundEnemy[0]);
	
	if (EnemyChar2)
	{
		Enemy = EnemyChar2->EnemyCharHealth;
	}
	else
	{
		GLog->Log("EnemyChar:Null");
		
	}

}