Beispiel #1
0
    void OnBallPosMessage(NetworkMessage msg)
    {
        BallPos pos = msg.ReadMessage <BallPos>();

        ballPos.x = pos.px;
        ballPos.y = pos.py;

        RpcSetBallProperties(pos.id, pos.px, pos.py, pos.vx, pos.vy);
    }
    public static void SendBallPos(float px, float py, float vx, float vy)
    {
        if (client == null)
        {
            return;
        }

        BallPos msg = new BallPos();

        msg.id = connId;
        msg.px = px;
        msg.py = py;
        msg.vx = vx;
        msg.vy = vy;

        client.Send(PongMsgType.BallPos, msg);
    }
Beispiel #3
0
 // Start is called before the first frame update
 void Start()
 {
     gameSession = FindObjectOfType <GameSession>();
     ball        = FindObjectOfType <BallPos>();
 }