Editor Freeze and Crash when Attempting World->SpawnActor

Guys do you know if there are any other setups i must do before spawning a actor in the Level? In my project there are various places that i spawn actors. But in this specific case, everytime this function is called my game Freezes and then crashes. I don’t have the slightest idea why. The code is almost the same in every place but in this class that it simply Crashes. Just to understand the class it is a Torpedo that when he explodes he spawns an explosion actor to deal damage. It so simple but it breaks the entire execution.

Please someone help me on this.

Code:

void ATorpedoTrap::Explode()
{
   //Clear Any Timers
   GetWorldTimerManager().ClearAllTimersForObject(this);
   TorpedoUpdateTimeline.Stop();


   //Check for a valid world
   UWorld* const World = GetWorld();
   if (World)
   {
      //Set the spawn parameters
      FActorSpawnParameters SpawnParams;
      SpawnParams.Owner = this;
      SpawnParams.Instigator = Instigator;

      // Get Actor Location to Spawn
      FVector SpawnLocation = GetActorLocation();

      //Set a rotation
      FRotator SpawnRotation = GetActorRotation();

      // Spawn the pickup
      AActor* const SpawnedActor = World->SpawnActor(Explosion, SpawnLocation, SpawnRotation, SpawnParams);


      //Setup the Explosion params
      AExplosion* Explosion = Cast(SpawnedActor);
      if (Explosion) 
      {
         Explosion->Setup(2.f);
      }
   }
   if (!Destroy())
   {
      //Treat Powerup Failded destruction
      UE_LOG(LogClass, Log, TEXT("Not able to destroy actor"));
   }
}

Hey LuLima-

Can you post the callstack and log files from the crash for additional information? Also let me know if there is any difference if you remove line 14. If you’re able to add a breakpoint to the function above, at what point is the breakpoint triggered?

Cheers

On the crash report in all the lines of code. my classes that appear are:
UE4Editor_BattleSubs_8927!ATorpedoTrap::Explode() [d:\unrealprojects\battlesubs\source\battlesubs\torpedotrap.cpp:106]
UE4Editor_BattleSubs_8927!ATorpedoTrap::execOverlapBoxBeginOverlap() [d:\unrealprojects\battlesubs\source\battlesubs\torpedotrap.h:14]

On the Saved/logs this shows up like this

[2016.02.17-16.00.29:248][380]LogWindows:Error: === Critical error: ===
Fatal error!

[2016.02.17-16.00.29:320][380]LogExit: Executing StaticShutdownAfterError
[2016.02.17-16.00.29:322][380]LogOutputDevice:Warning:

Script Stack:
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxBeginOverlap
TorpedoTrap.OverlapBoxB… and this repeats like to infinity

Removed line 14 still crashed.

When i placed a breakpoint and tried to follow it never got to the cast… It kept jumping back to params and my location and rotation.

Can you post the callstack and log files in their entirety? If you save the callstack as a text file you should be able to zip both files together and post here. Also, it looks like the crash points to line 106 of the Torpedotrap.cpp file which appears to be the Explode() function, is that correct? Can you identify which line of code is at line 106 in Visual Studio?

It is exactly the spawn instruction. But i seem to have found the problem looking at the the crash log created in the saved directory. When i spawn the explosion it is calling the torpedos overlap box infinite times so thats crashing the editor. the weird thing is that it doesn’t happen to the other actors that have the same behaviour.

Anywho, I disabled the generate overlap of the torpedo before exploding it and that solved the problem.

thanks for pointing me in the right direction , bless you!

I’m glad to hear that you were able to find the solution. To prevent such a crash in the future it would help if you could post your callstack and log files as well as providing the setup for your actor and the reproduction steps that cause the crash.

Hi LuLima,

We have not heard back from you in a few days, so we are marking this post as Resolved for tracking purposes. If you are still experiencing the issue you reported, please respond to this message with additional information and we will offer further assistance.

Thank you.