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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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, ...
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 ...
2
votes
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 ...
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 ...
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 ...
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 ...
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 ...
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-...
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 ...
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, ...
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:
...
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 ...
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 ...
1
vote
Accepted
Prevent parent alarms to activate a child alarm event
Instead of
o_enemy.alarm[0] = value;
Try something like this
...
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 ...
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......
...
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,...
1
vote
Start Countdown on Resuming Game (Unity)
Use WaitForSecondsRealtime on the place of WaitForSeconds. It will work.
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.
...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
timer × 179unity × 45
c# × 32
c++ × 22
java × 15
javascript × 15
game-loop × 12
android × 10
events × 10
animation × 9
timestep × 7
timing × 7
xna × 6
html5 × 6
optimization × 6
gamemaker × 6
frame-rate × 6
opengl × 5
2d × 5
game-design × 5
time × 5
libgdx × 4
movement × 4
input × 4
client-server × 4