Need Assistance With Global Speed Adjustments

Peace Unto You!

I need assistance with making a system that slows down the entire game temporarily. I heard unity has something implemented within the game, and also heard Defold doesn’t necessarily have the same method but similar ones. May someone please guide me on how to globally change the speed of the game when pressing a gui node?

I already got the gui node and everything set up, I just am having issues trying to figure out how to slow the entire game down. I thought it was easy cause emulators literally have fast forward and slow down features built in, though that is, may someone please assist me?

You could use this

Ciao!

2 Likes

Example Time-step

Peace Unto You! Thank you all for the assistance! This got me one step closer, though that is, I’m still experiencing some issues. So since I need to make it to where when I press my gui node the time slows down by 50 percent for 3 seconds then reverts I got this code set up for my power gui

function on_input(self, action_id, action)
-- Check if the button is clicked and released
if gui.pick_node(gui.get_node("power"), action.x, action.y) and action.released then
-- Start The Power Up
msg.post("main_game", "set_time_step", {factor = 0.5, mode = 0})
print("Delay In Effect")
timer.delay(3.0, false, msg.post("main_game", "set_time_step", {factor = 1.0, mode = 0}))
end
end

I’m still having issues cause it’s not working.

So my entire set up is I changed the loader collection to load the main game through a proxy and in the main collection is my power go and in my power go I have the power gui, now the proxy in my loader collection is called “main_game”, so what am I doing wrong? When I click on the icon I have for the power up nothing happens

Your timer callback is wrong. Currently you are calling the function msg.post when starting the timer, and return nothing as callback. You have to create a new function that is created as callback for the timer to call after the delay is done. Like this:

timer.delay(3.0, false, function() msg.post("main_game", "set_time_step", {factor = 1.0, mode = 0}) end)

To make it more clear, it is the same as this:

local function callback()
    msg.post("main_game", "set_time_step", {factor = 1.0, mode = 0})
end
timer.delay(3.0, false, callback)

But what you did was this:

timer.delay(3.0, false, callback())
1 Like

Peace Unto You! Thank you! So just to see if it would work, I just removed the timer completely and it still doesnt work. May someone please give me a step by step on what to do in my situation cause what im asking for is simple, but im having a lot of issues trying to implement it.

I quite frankly am having trouble innerstanding how to get the time step to work. I already read the tutorial multiple times, and seen the example but it doesnt apply to my specific situation cause its not working.

So I would need a step by step on how to implement this cause its not making sense. I have a loader script that loads a proxy called “main_game”, and this proxy loads the main collection called “main” and in the main collection I have a go that is called “power”, and in this go is the power gui containing the gui and gui script handling the code I provided. Based on the tutorial it should be working but something im doing is not right somehow

Blockquote

I would suggest that you, as a test, try to set the time step from your loader collection on the main_game proxy. Does that work?