I am trying to make an army troop that fires a projectile on other actors when in range. However my Fire() function seems to cause Unreal to crash due to an Exception Access Violation. How can I stop it from crashing?


In Fire you are spawning the projectile via the spawn actor function that takes in a class. In your case Projectile class. It is probably not set.

Before calling the spawn function check against a nullptr

if(ProjectileClass != nullptr){
// spawn projectile
}