shahilsaha

Fix for App crash on enemy controller assigned

May 25th, 2024 (edited)
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | Source Code | 0 0
  1. void UEnemySubsystem::RequestEnemy()
  2. {
  3.     if(TotalEnemiesToSpawnThisRound-- == 0)
  4.     {
  5.         GetWorld()->GetTimerManager().ClearTimer(EnemySpawnTimerHandle);
  6.         EnemySpawnTimerHandle.Invalidate();
  7.         return;
  8.     }
  9.  
  10.     // Clear and invalidate the timer if the remaining enemies to spawn is 0
  11.     const auto SpawnPoint = GetRandomEnemySpawnPoint();
  12.  
  13.     const auto Controller = mFreeControllers.Pop(true); // take out a free controller
  14.     Controller->SpawnPawn(SpawnPoint);  // spawn the pawn
  15.     mAllocatedController.Add(Controller);   // add it to the allocated controller
  16. }
  17.  
Advertisement
Add Comment
Please, Sign In to add comment