Exemplo n.º 1
0
 private void OnDestroy()
 {
     // Send to network
     if (NetCode.IsConnected)
     {
         var cmd = new Command(OpCode.Disconnect);
         NetCode.Send(cmd);
     }
 }
Exemplo n.º 2
0
 // Update is called once per frame
 void Update()
 {
     if (elapsedTime >= period)
     {
         // Send a ping!
         NetCode.Send(cmd);
         elapsedTime = 0;
     }
     elapsedTime += Time.unscaledDeltaTime;
 }
Exemplo n.º 3
0
    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);
        }
    }
Exemplo n.º 4
0
    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;
        }
    }