#Can't call non-static method from static method

1 messages · Page 1 of 1 (latest)

barren hawk
#
private void SetTick(ushort serverTick) {
  if(Mathf.Abs(ServerTick - serverTick) > tickDivergenceTolerance) {
    Debug.Log($"Client tick: {ServerTick} -> {serverTick}");
     ServerTick = serverTick;
  }
}

[MessageHandler((ushort)ServerToClientId.sync, NetworkManager.MessageHandlerGroupId)]
public static void Sync(Message message) { // static function
  SetTick(message.GetUShort()); // non-static function should get called
}
#
error CS0120: An object reference is required for the non-static field, method, or property 'ClientPlayer.SetTick(ushort)'
#

so you don't need to mind the network stuff but the important parts are the one marked

#

it's in the same script so how could i make this work

#

i dont want to create an instance just in case you are thinking of it