private void OnDestroy() { // Send to network if (NetCode.IsConnected) { var cmd = new Command(OpCode.Disconnect); NetCode.Send(cmd); } }
// Update is called once per frame void Update() { if (elapsedTime >= period) { // Send a ping! NetCode.Send(cmd); elapsedTime = 0; } elapsedTime += Time.unscaledDeltaTime; }
public void Jump(float jumpMult = 1) { float velY = jumpHeight * jumpMult; pm.Jump(velY); // Send to network if (NetCode.IsConnected) { var cmd = new Command(OpCode.Jump, velY); NetCode.Send(cmd); } }
public void Move(float moveX) { float newX = Mathf.Max(-1, Mathf.Min(1, moveX)) * speed; if (newX != this.velX) { pm.MoveX(newX); if (NetCode.IsConnected) { var cmd = new Command(OpCode.Move, newX); NetCode.Send(cmd); } this.velX = newX; } }