The tickcount trick

You're viewing a single comment in a conversation. View all the comments
  • 2 Comments

  • Order by
  • Thank you, that's helpful. One more question...

    What does the "% 2" mean? I'd like to understand exactly what is happening here.

    • % is the modulo operator. Basically a%b returns the rest of the euclidian division of a by b. Put in other words, you remove b from a as long as a > b

      12%7 = 5

      100%10 = 0

      3%8 = 3

      So what that means is that it will execute the action only when tickount%2 is equal to 0. This is true when tickount is even. So it will only execute the action when tickcount is even AKA every two frames.

      Changing the number after the modulo increases the number of frames it will wait before performing the action.