Destroying actors
So far in this chapter, we have put a lot of focus on spawning, or creating, actors inside the game world; the player character uses the UWorld class to spawn the projectile. UE5 and its base Actor class come with a default function that you can use to destroy, or remove, an actor from the game world:
bool AActor::Destroy( bool bNetForce, bool bShouldModifyLevel )
You can find the full implementation of this function in Visual Studio by finding the Actor.cpp source file in the /Source/Runtime/Engine/Actor.cpp directory. This function exists in all the classes that extend from the Actor class, and in the case of UE5, it exists in all classes that can be spawned, or placed, inside the game world. To be more explicit, both the EnemyBase and PlayerProjectile classes are children of the Actor class, so they can be destroyed.
Looking further into the AActor::Destroy() function, you will find the following line:
World->DestroyActor( this, bNetForce, bShouldModifyLevel...