The game paused but factoried objects can not stop

Hi guys

I am trying to switch between menu and the level
but I found a problem ,in the level i have some factory to generate enemies, they will move towards the player.
the problem is when i call the menu ,the game needs to pause, i used set_time_step to pause the game, it seens worked but a little problem, the enemies already created can not stop moving to the player.
i dont know whats going on with it ,did I miss someting to do?

thanks

the code of collcection controller

function init(self)
	msg.post(".","acquire_input_focus")
	msg.post("/collections#gameplay","load")
end

function on_message(self, message_id, message, sender)
	if message_id == hash("proxy_loaded") then
		--msg.post(sender,"init")
		msg.post(sender,"enable")
		msg.post(sender,"acquire_input_focus")
	end
end

function on_input(self, action_id, action)
	if action_id == hash ("upgrade") and action.released then
		
		msg.post("/collections#gameplay","set_time_step",{factor = 0, mode = 1})
		msg.post("/collections#upgrade_gui","load")
	end
	
end

Is the enemy factory in the game collection?

yes ,the enemy factory in the game collection.

here is the collection outline

the rapid,square,triangle factory is the enemy factories

I also record a video.
when i call the menu display,all the enemy was stop rotate but could not stop moving.
I print the dt value of the game collection and the square enemy ,they are all zero.

DEBUG:SCRIPT: update() with timestep (dt) 0
DEBUG:SCRIPT: SQUARE update() with timestep (dt) 0

I’d use a boolean variable to control pausing. Post a message to change the variable and in the update method check that variable.

if self.is_paused then return end

Also, do you use physics?

thanks! I will try it.
I did not use physics on this game

HI sergey

your solution works though the code was a little complicated. thanks!

but i still confuse about the reason why when dt = 0 the update function still can execute?

1 Like

The update function will still be called but as you can see from dt the time is not advancing. Aren’t you using dt when procedurally moving the enemies? go.animate would also not advance.