[Solved] Weird issue with Timer

Hi guys,

So I have a power-up called Pepper that gives your character an attack boost for around 10 seconds. I want this power-up to appear at random every 6 with 25 seconds.

Below are the events for the Pepper power up

Basically once the timer “GameProgress” reaches 5 seconds the game starts the timer for the spawner of the power-ups.

Now this thing works fine until we reach 35 seconds in the game.
Once the “GameProgress” timer hits 35 I have the below events that occur in order for the camera to zoom out and expand the map.

For some reason, once this happens the Peppers stop spawning. It’s like their timer breaks or something, I don’t know why this happens. I tried to disable the above events and the peppers work fine when I do that so the problem really occurs due to this event.

I really don’t know what the issue is.

The below variables
SheepSpawnPosition[0]
SheepSpawnPosition[1]
SheepSpawnPosition[2]
are coordinates for most of my objects in order to update their spawn position once the camera zooms out, it shouldn’t really affect the peppers. The rest of the objects such as coints,sheep etc are working find once the camera zooms out and all of them have timers as well.

I have a feeling that the timer “GameProgress” may be the culprit here, but why?

Once the condition to this event is true, it is being run every single game frame for 2 seconds, because the conditions don’t change to prevent the event from occurring again. Is this what you’re after?

But this wouldn’t explain your issue. What happens in the events that set the variable CameraZoom to 0? And what happens when CameraZoom is 1?


Also, this event


will generate a random value every game frame. This will most likely end up spawning a new pepper close to every 6 seconds. You could instead replace the random function with a variable that gets set to Random(6, 25) whenever the PowerUpPepper timer is rest.

1 Like

Thanks for answering!

I have the camera event to run every frame in order for the camera zoom extension to run properly. For some reason It wouldn’t work when I had the trigger once condition, not sure why, maybe I was doing something wrong.

As for the timer for the Pepper, this makes sense wow, I never thought about it that way. Will it still generate every frame if I add a trigger once condition? I was actually thinking of adding a variable there but since RandomInRange was allowed I thought it would be easier to handle.

Still this doesn’t explain why the timmer for the Peppers stops working after the game progress reaches 35 seconds. By that time the timer of the Pepper should not be related to it.

If you use a trigger once then it only gets actioned once while the conditions are true.

It looks like you’re trying to do 3 different things in one event - continuously zoom the camera, set some variables and wait for 2 seconds before resetting another variable.

Look at splitting these up into their separate requirements

  • setting the array variables once and create a zoom timer
  • while the zoom timer is less than 2 seconds update the zoom.
  • when the zoom timer passes 2 seconds, set the CameraZoom variable.

Agreed, which is why I asked about other events that work the CameraZoom variable.

1 Like

Just realised that I never updated this thread.

The problems was me. (Like most of the time)

I had the “Destroy outside screen” behavior on my pepper object so when the timer was reaching 35 seconds because the spawn coordinates were changing over the limit the pepper was been deleted before it could get inside the screen.

1 Like