public static void updateStateFromNetwork(this CarActor carActor, PacketReader reader) { // read values and apply to carActor: // position and orientation and velocity carActor.WorldTransform = reader.ReadMatrix(); carActor.LinearVelocity = reader.ReadVector3(); carActor.AngularVelocity = reader.ReadVector3(); }
public void ReadNetworkPacket(PacketReader packetReader, GameTime gameTime, TimeSpan latency, bool enablePrediction, bool enableSmoothing, float packetSendTime) { if (enableSmoothing) { previousState = displayState; _currentSmoothing = 1; } else _currentSmoothing = 0; //float packetSendTime = packetReader.ReadSingle(); simulationState.Position = packetReader.ReadVector3(); simulationState.Velocity = packetReader.ReadVector2(); simulationState.Rotation = packetReader.ReadSingle(); PositionInput = packetReader.ReadVector2(); RotationInput = packetReader.ReadVector4(); if (enablePrediction) ApplyPrediction(gameTime, latency, packetSendTime); }