Good afternoon.
It is necessary to rewrite this block of blueprints on C++. Logic is such that every enemy that enters the radius of the tower gets into the array of this tower. For example, if there is 1 enemy on the field, and falls into the view of 4 towers, then in the array of each tower there will be 1 element - this enemy.
- How to implement “Cast To Enemy” on C++?
- The array in the BP consists of Enemy Object References, how to do this in C++?
TArray<AEnemy*> arrayOfEnemy; // Such array is necessary?
// On example of the enter to collision
void ATower::OnOverlapBegin(UPrimitiveComponent * OverlappedComp, AActor * OtherActor, UPrimitiveComponent * OtherComp, int32 OtherBodyIndex, bool bFromSweep, const FHitResult & SweepResult)
{
if (OtherActor && (OtherActor != this) && OtherComp)
{
AEnemy *enemy = Cast<AEnemy>(OtherActor); // Cast is correct?
this->arrayOfEnemy.Add(enemy);
}
}