Avoid array resizing with ranged for loop
This commit is contained in:
parent
56d4c5f5b4
commit
6a97c425d7
@ -189,8 +189,10 @@ void AEnemyCharacter::ResetHealth()
|
||||
|
||||
void AEnemyCharacter::DamagePlayer()
|
||||
{
|
||||
for (auto DamagedPlayer : Player)
|
||||
if (Player.Num() == 0) return;
|
||||
|
||||
for (int i = 0; i < Player.Num(); i++)
|
||||
{
|
||||
UGameplayStatics::ApplyDamage(DamagedPlayer, Damage, GetController(), this, nullptr);
|
||||
UGameplayStatics::ApplyDamage(Player[i], Damage, GetController(), this, nullptr);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user