Time in frames

  • Similarly to how some behaviours let you use screen % instead of metres, things with durations (more specifically Timers and Waits) could have the option to work in frames rather than seconds. As it is now, to have a timer for every frame you would use 0s, or 0.01666...s (since 0s can have some problems). It would be pretty cool to be able to choose how many frames something waits or delays in a timer, instead of multiplying 0.01666... by the amount of frames delay you want. Also that makes me wonder whether it is possible for a timer running on 0.01666...s to ever skip a frame.

  • Admin

    This isn't the best approach of doing this.
    Frames are not consistent, so you don't actually want to do anything based on frames. On some devices (or due to behaviour logic) this can result in slow motion, or fast motion. Kind of unpredictable.

    What you would want to do is something in every render cycle (Some people call these "ticks". While we don't expose this exactly, timer of 0 is pretty much this.

    If you do in fact want to wait for a certain amount of frames, then what you can do is use the play animation behaviour and have an animation with your desired frames playing some where off screen. Then when the animation is done do some thing. It's kind of a hacky trick. But may work depending on what you're trying to do.

  • @murtaza I suppose render cycle might've been more what I meant. I didn't know the difference between frames and render cycles even existed. Timer 0s doesn't seem to work properly (at least not in movement behaviours), have timer 0s → move by some small distance, the object seems to stutter every second, but timer every 0.01666... doesn't.

    So how does this difference work? At maximum performance, a game runs at 60 frames per second, but how many render cycles? If the game starts lagging, do both of these slow down, or just the frames?

  • Yeah, sometimes Timers don't cooperate with transform behaviors. Objects stutter behind. You can see some graphical glitches on my latest game due to this. I think there is a way around it, it just may be very complex to do.

  • @aidan-oxley a while back I had a timer of 0 moving an object, and had to use 0.01666 too.

    I don’t know if this is right, but when I looked it up I found that it had to do with movement on a 0 timer not always being in sync with the frames.....so like the object might move twice between frames and then once between the next frames. Maybe just if the the fps fluctuated.
    But if the timer is 1/60 or 0.01666... It supposedly keeps the movement in time with the frames.

    Not sure if this is actually true, but it seems to work.

Log in to reply

Looks like your connection to hyperPad Forum was lost, please wait while we try to reconnect.