Multiplayer game "tick" time

Hello!
I’m making a fighting game with Unity with online multiplayer, but I have huge problems with making unity “tick” how I want.
In fighting games frames are really important, and my game works with one inputbyte that gets sent over the network.
However, I have no clue how to make my update go no faster than 30fps. Or rather, I don’t care that much about the graphics, that could work 60fps just as fine. I want my gamelogic to run at 30fps, or at least not any faster than that. I tried using fixedupdate with set timestep, but that doesn’t seem to be working at all! If I call a debug log in fixed update, it does it as it pleases, or so it seems at least. Also inputs don’t work in fixed update at all.

Any help on the matter? I read the Valve’s multiplayer principles, and they state source has fixed 15ms timesteps called “ticks”. I want to make my game tick with 30ms.

then use 2 ticks for it
if(tick %2)

What you are looking for is to “fix” your timestep, to make sure you ALWAYS get 30 ticks per second that passes, the way you do this is either use FixedUpdate and set the physics rate to that exact rate, 0.03333333… seconds that is. Or you can do it manually inside Update, with something like this:

double acc = 0;

void Update() {
    acc += Time.deltaTime;

    while(acc >= 0.03333333) {
         Tick();
         acc -= 0.03333333;
    }
}

void Tick() {
}

Also due to the ever-repeating nature of dividing 1000 with 30, I would advice you to go with an update rate that can divide 1000 without any fractions, for example 40 or 50 updates/second or something.

1 Like

I think you should use InvokeRepeating function. In your start call it
InvokeRepeating(“LogicFunction”,0,0.333f);
and then that LogicFunction is called each 0.333f for you.