Skip to main content
5 votes
Accepted

How do I blink a sprite a few times before it disappears?

It appears you want Blink to be executed as a coroutine. But you are executing it directly. If you call an IEnumerator method directly, you receive an ...
Philipp's user avatar
  • 123k
4 votes
Accepted

Is Time.deltaTime different on various devices?

On some platforms the game actually starts running before the splash screen is gone. So this may give the illusion of a defective timer if you test it right at the start. Another issue on slow ...
Stephane Hockenhull's user avatar
4 votes
Accepted

Saving total play time could be fine?

Floating point precision is unlikely to be the problem here. Since you're not trying to coordinate simultaneous use, but just determine which of two sequential sessions came earlier/later, you'll ...
DMGregory's user avatar
  • 141k
3 votes
Accepted

Phaser 3 - How to trigger an event every 1 second?

In your scene's update method you receive both the current timestamp, and the delta since the last update call (see https://photonstorm.github.io/phaser3-docs/Phaser.Scene.html#update__anchor) You ...
vassildador's user avatar
3 votes

How do I blink a sprite a few times before it disappears?

When you call Blink you are discarding its return value: Blink(itemClone); You do not want to do that. I believe you want to ...
Theraot's user avatar
  • 28.2k
3 votes
Accepted

Timer breaks after changing scenes

Time.time returns the number of seconds since the start of the game. "Start of the game" refers to the moment the game was launched, not the moment the current ...
Alex Myers's user avatar
3 votes

Timer as part of a condition

Myself, I'd recommend separating the jobs of reading from the sensor, running your timer, and coordinating your scene transitions. This way each script can do one simple job, so you don't end up with ...
DMGregory's user avatar
  • 141k
3 votes
Accepted

Time based events separate from the game loop

This is a very wide question, and difficult to answer specifically, so I will be general instead: Any "over time" effects will still be based on your game loop, but have their own "tick" of time they ...
Ian Young's user avatar
  • 2,694
3 votes

Time based events separate from the game loop

Time elapsed events are not separate from the game loop but are controlled from the game loop. The easiest way to achieve the effect is to have a floating-point value that represents the number of ...
Casey's user avatar
  • 2,095
3 votes

How to structure a game that continue even when closed?

The proper way to do this is, when you exit the game, save the current time somewhere in your project. My .Net skills are awful, but a quick google search suggests ...
Tom Tsagkatos's user avatar
2 votes

SDL - Limiting loop with timer? Not polling

SDL_AddTimer is a problem here. SDL_AddTimer spawns a new thread, and things won't work like you expect when using multiple threads. When you call SDL_Init(), you likely do it from the main thread, ...
prushik's user avatar
  • 186
2 votes

Make timer for game to run for 2min

If you record the time once at the start of your game: time_t startTimeSeconds = time(NULL); // must include 'ctime' Every update (game loop iteration) you can ...
Quintin Steiner's user avatar
2 votes

Game time and pausing

My favorite way to pause a game is this: ...
Tom Tsagkatos's user avatar
2 votes
Accepted

Keep the timer counting after changing scenes

You can just put the line in the Unity API of DontDestroyOnLoad() inside Awake() method and your object will not get destroyed ...
John Hamilton's user avatar
2 votes
Accepted

To implement a game object that expires, should I store the start time and total, or store the remaining time?

There is no "best" way to do this, both methods are completely viable and personal preference. However I believe that the delta time version is superior because it's inherently less error-prone than ...
Applekini's user avatar
  • 8,543
2 votes

Use vsync event instead of a 16ms timer?

There are various reasons not to use the vsync event nowadays. Indeed, historically when the games had to sync with the refreshrate of the screen because the ‘redraw’ would be visible or cause a ...
Felsir's user avatar
  • 4,117
2 votes

Multiple events based on in-game timer?

You can also have a master "Schedule" that acts as a priority queue. This automatically sorts the next item to occur so that it's the first item in the collection (often more cheaply than ...
DMGregory's user avatar
  • 141k
2 votes

Multiple events based on in-game timer?

You're overthinking this. Polling the in-game time each frame is nothing compared to the other things your CPU does each frame. You would need millions upon millions of entities to see the a ...
Applekini's user avatar
  • 8,543
2 votes
Accepted

Unity3d Pause RigidBody object, don't stop time

Turn off auto physics simulation: https://docs.unity3d.com/ScriptReference/Physics-autoSimulation.html Or if you happen to be doing 2D: https://docs.unity3d.com/ScriptReference/Physics2D-...
Ed Marty's user avatar
  • 5,259
2 votes

Reacting to button holds of different durations for an anxiety game

It looks like you're also reading your input from a specialized device of some kind. I'll show a conventional version with Unity's built-in input first, for simplicity, then mention how we can ...
DMGregory's user avatar
  • 141k
1 vote
Accepted

How to make a countdown timer based on local time

It looks like you want to do something like this, using PlayerPrefs to store the state between runs of the game. (This is insecure, but so is using the local system time - if a player wants to cheat, ...
DMGregory's user avatar
  • 141k
1 vote
Accepted

the countdown timer inside while loop not working

Finally! After 3 days, I found the solution: I created a new script attached it to the 3d Text Add code to change the text: ...
Mr Salsa's user avatar
1 vote
Accepted

How to spawn enemies after a certain amount of time?

Your immediate problem is just a typo: >= is a "greater than or equal" comparison => defines a lambda expression, which is ...
DMGregory's user avatar
  • 141k
1 vote

Timer as part of a condition

If i understood you correctly, after force or amount > 0 we need to subtract some number from TimeLeft, and after 5 seconds pass, we level up, so move this sphere up. Correct me if i didn't get your ...
Nick's user avatar
  • 561
1 vote
Accepted

Prevent parent alarms to activate a child alarm event

Instead of o_enemy.alarm[0] = value; Try something like this ...
Dmi7ry's user avatar
  • 1,050
1 vote

Precision timing in Unity3d

Yes, You can use multi-threading which is not recommended in many cases but it can be used if threads are managed correctly and made sure that Unity API is being called from main thread only. Read ...
Umair M's user avatar
  • 236
1 vote

How to stop an anmation and a loop in relation to a timer? Phaser javascript

I found out what it was. It was missing a callover, as in: var callGameover = false; and...... ...
DjangPhaser1's user avatar
1 vote

Fixed timestep updates with a variable timestep update

The reason we do fixed timestep updates in the first place is to ensure our realtime game simulations stay consistent. Take a simple object falling under gravity of -9.8 m/s^2 under Euler integration,...
DMGregory's user avatar
  • 141k
1 vote

Start Countdown on Resuming Game (Unity)

Use WaitForSecondsRealtime on the place of WaitForSeconds. It will work.
Mamta's user avatar
  • 11
1 vote

Creating a countdown Timer in Unity

This seemed a simple solution: you can use st.Reset() etc as you need in your own code. ...
wax_lyrical's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible