Game lags when object creation

Hello guys ,
My game lags a moment when objects start to created. There are a spawning point and enemy objects spawning from there but there is hapenning a little lag but its really annoying .
Here i am sharing the project file link below.:
project file
Enemies start to spawning between 5 and 10 second.Keep firing and listen the sound.And than watch player is lagging too. Play with spawning interval as you wish it’s always lags.
The game is really simple and i couldn’t figure it why it is lagging.Any idea ?

1 Like

Usually, lags are due to actions repeating again and again, and, usually, this is solved by adding a Trigger once condition.

1 Like

It is true what Gruk mentioned but In this case, it is caused by the physics behavior.
When you create an enemy for the very first time, it is when the physics engine get initialized and this is cause the lag at first. The solution is to put a physics object in to the scene just to initialize the physics engine at the beginning.


Thanks for inspecting the project guys , in my case i wasn’t able to use trigger once cause i want multiple enemies, but forcing physics module initialized at start really worked . I just placed a physics behavior object outside the screen. Thank you !