Exemple #1
0
        public void SendPlayerUpdate(Vector3 position, Quaternion rotation)
        {
            PlayerPosition packet = new PlayerPosition();

            packet.Generate(userName, ConvertCustomTypes.ConvertVectorSerializable(position), ConvertCustomTypes.ConvertQuaternionSerializable(rotation));
            ZeroGPacket mainPacket = PacketGenerator.Generate("PlayerPosition", packet);

            gClient.Send(mainPacket, LiteNetLib.DeliveryMethod.Unreliable);
        }
Exemple #2
0
        public static void Process(PlayerPosition packet)
        {
            Main clientInst = InstanceKeeper.GetMainClient();

            foreach (GameObject gameobject in clientInst.playerShips)
            {
                ZeroGPlayer playerName = gameobject.GetComponent <ZeroGPlayer>();
                try
                {
                    if (playerName.PlayerName == packet.PlayerName)
                    {
                        gameobject.GetComponentInChildren <PlayerObjectConfiguration>().GetShip().transform.position = ConvertCustomTypes.ConvertVectorOriginal(packet.Position);
                        gameobject.GetComponentInChildren <PlayerObjectConfiguration>().GetShip().transform.rotation = ConvertCustomTypes.ConvertQuaternionOriginal(packet.Rotation);
                    }
                }
                catch (Exception ex)
                {
                    WriteLog.Error("Error while processing remote player movement: " + ex.Message + ex.StackTrace);
                }
            }
        }