2
$\begingroup$

The following image represents a timer with minutes and seconds that I created: timer

  • What is the correct value of the "skip" option in the always sensor if I want it to activate every 1 second?
  • Also, what is the connection, if any, with the "animation frame rate" under the "display" section in the "render" toolbar?
  • And at last, is there any connection between one of the above values and the fps of my game? Will those values be affected by the fps of my game somehow or the other way around?

Thanks

$\endgroup$
4
  • $\begingroup$ Funny. Someone renamed "Freq:" to "Skip:". I think it is still misleading. It is a period or delay between to consecutive triggers when the sensor's evaluation state does not change. I understand "skip" as a flag that is either True or False, but not a number. Anyway it does not help your problem, but why you can't find something when you search for that parameter. $\endgroup$
    – Monster
    Commented Aug 26, 2015 at 5:18
  • $\begingroup$ Please post just one question at the time. $\endgroup$
    – Monster
    Commented Aug 26, 2015 at 5:56
  • $\begingroup$ Thanks, I only asked those questions together cause I thought they had a connection due to a video I watched. $\endgroup$
    – Lev
    Commented Aug 26, 2015 at 11:00
  • $\begingroup$ No big deal, I could see the connection. The problem is that it it is (in a lot of cases) difficult to give one answer for several questions. I think in your case it was possible to do that. $\endgroup$
    – Monster
    Commented Aug 27, 2015 at 4:35

1 Answer 1

4
$\begingroup$

The default (logic) frame rate is 60 frames/sec. Therefore 60 is a good value for your purpose.

There are more frame rates:

  • Animation frame rate (usually 24 frames/sec) used to play actions.
  • Physics frame rate (usually matching the logic frame rate) to calculate the physics influence to a scene. Be aware it can be even finer with so called-substeps. More sub steps increase the precision of the physics calculation (but costs more processing time).
  • Render frame rate (usually matching the logic frame rate) which tells how many images are rendered. If a frame lasts too long (exceeds the 1/60 time available) the BGE starts skipping the render trying to meet the frame rate. This can happen up to 5 times in a row. After that there is a forced render ignoring the time limit. The render frame rate is never higher than the logic frame rate as it is assumed there is no change to the scene and the output would be the same.

But:

I suggest to avoid this method to measure time. The BGE will try to keep the given frame rate as much as possible, but there is no guaranty.

I recommend to use a timer property. It counts the seconds. I think that is what you really want.

Then you have several ways to show the time. I think you want to format it to minutes:seconds. You can use this little script timeToText:

import bge
from datetime import datetime

textObject = bge.logic.getCurrentController().owner
time = datetime.fromtimestamp(textObject["time"])
textObject.text = '{:%M:%S}'.format(time)

It expects a property time to provide the seconds and should be applied to an text object.

enter image description here

You can indeed refresh the display each 60 frames. But you will not know when the seconds changed. Therefore I suggest to run it constantly.

Hint: If you want to show microseconds too, use this format: {:%M:%S.%f}

$\endgroup$
2
  • $\begingroup$ I am gonna post a question about inverting the timer and quote part of your answer. If you know how, feel free to answer. Thanks again for your elaborated answers. $\endgroup$
    – Lev
    Commented Aug 26, 2015 at 11:18
  • $\begingroup$ I think you can simply copy&paste the text from here and use the block quotation button <ctrl+Q> when editing your post. $\endgroup$
    – Monster
    Commented Aug 27, 2015 at 4:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .