Timer not working

Hi everyone,

I am quite new to Gdevelop and the function. I am making a game which requires to hide and show objects. I am making a function for this and I want to type in the time which it requires to go from left to right. But it executres the code and the timer doesn’t reset itself. Maybe it is something in the expressions. How do I fix this??

always trigger once?! LoL.
and exactly when are you want reset the timer? because that is not clear from the question.

Ahahah the always, once is really dump xD. I am trying to create a stacker game. I made 7 cubes wich I want to move from left to right and back. I want it to repeat the animation until a key is pressed.

I found a video of it: LAI Games Stacker Club Prize Redemption Arcade Game! - YouTube

The action is around 20 seconds.

I try to figure out what happens :smile: .
I’m not sure how this game works in the video, but you need to find the point from which the process repeats itself, and reset your timer there. at the endpoint. for example in the last event.

I have a timer reset at the bottom but somehow it executes the code but not following the timer. If I put the left 3 blocks at the bottom of the code it shows those, but if I put the left 3 blocks in the bottom it shows those. There is no movement.

did you fix the always trigger once in the beginning? the timer start once when the function starts?
have you tried this method without function?
isn’t there a spelling mistake somewhere?

are you at all sure this is the best solution for the task?

Can you show us how you use the function in the events sheet? :slight_smile:

Of course:

Yes I fixed the always first, it is now in the beginning of the scene.
Yes the timer only starts in the function.
I made the function because otherwise the code was going to get too long, and therefor it worked like it should have worked.
I checked for spelling mistakes, even changed it to “1” just to be sure.
I thing it is the best way because there isn’t going on very much at the same time, so I think there is going to be a lot of lagg or anything.

my first thought was the “at the beginning of the scene” too. but I tried to use that condicion before in an externa event, and that isn’t work there, because the external event executed later. so I’m not sure it will be good. and if you start the timer at the beginning of your main event sheet, enough tome can pass to it, when you execute the function all the events will be true in it at the same time. so may be the best method for this is reset/start the timer when you enter in the function. in its first event with a “trigger once”.

it’s OK, but when something doesn’t work the way we imagined, we try to rule out possible sources of error, to find the real reason. thats why I ask. may be parameterizing of the function causes the problem, may be the timer, may be something other. everything must be ruled out.

by the way I’m not sure moving (repositioning) only one object cause more burden than playing with the visiblity of many. and may be its easier to realize.

You call your function only once at the beginning, so it runs one cycle and stops.
Remove the condition if you want your cycle to repeat.