Skip to main content

Common problems

My inputs seem to work for a split second, but then they are reversed

Example: you press a spacebar, the player jumps for a few miliseconds but then teleports back to the ground.

This usually happens when you modify the game state immediately on player input, instead of sending your input through the IInputHandler. This causes the server to overwrite your local changes on the next tick.

info

The only way for a player to modify the game state is through Player Inputs, sent and received via IInputHandler.

The input is jittery and feels unresponsive

Example: you press a spacebar and sometimes the player jumps, but sometimes this input is ignored.

Inputs are collected in IInputHandler during Elympics Update, which happens during FixedUpdate, not every frame! This means that you should avoid using methods like GetKeyDown or GetKeyUp.

Reconciliation happens every frame and kills my framerate

Example: the game starts and the framerate immediately drops and in the console window I see a lot of "Reconcilation" warnings

Your client is probably trying to predict something that is not predictable for them, like other player movements. Only use prediction on objects you control, or objects no one controls.

My input is visible in my game, but not for other players

Example: I press a spacebar and I see myself jump, but other players don't see this.

Either you don't send your input through IInputHandler or you don't synchronize its effects. Every input has to be sent using IInputHandler, and the code that applies it in IInputHandler must modify a custom ElympicsVar or a synchronised component on a ElympicsBehaviour, like rigidbody or transform.

The same object has different positions on connected clients

Example: two players ale playing football and the ball has a different position for everyone

This basically means that the position of this object is not synchronised. This can happen for a couple of reasons:

  1. This object doesn't have an ElympicsBehaviour component
  2. This object has an ElympicsBehaviour component, but doesn't have position synchronisation turned on
  3. You have some custom logic that moves the object that is not a synchronised input (see "My input is visible in my game, but not for other players")
  4. You instantiated an object without using ElympicsInstantiate
  5. You tried to add the ElympicsBehaviour component dynamically to an existing object - this is not supported
  6. You created a new ElympicsVar instance after scene initialization - this is not supported

I want to execute some code only on the server. Is there any isHost property?

In Elympics SDK you can use if (Elympics.IsServer) { ... } to ensure that code runs only on the server. However, the use cases are a bit more rare than in client-authoritative code, because large parts of the code are predictable, and can be run both on clients and on the server.

Use cases

Use cases in which it is a good practice to perform code on the server only are:

Code that is not predictable

For example everything that involves randomisation, like spawning random items, map generating etc. Enabling the client to predict this will result in costly and unnecessary reconciliations.

Code that is hard to roll back

Every prediction might be wrong, so if the effects are highly impactful for the gameplay and hard to reconcile, it's better to not predict them. For example, dying from damage - if a client predicts its death, it will show the deathcam, the visual effects, sound effects, lock player input, and start a respawn countdown. Reconciling all these things will not only be complicated, it will also look bad, as if the game glitched and broke and it will be very confusing for the player.