Prediction Serializers

You may also create custom serializers for your prediction data types. A video on using prediction may be found at https://www.youtube.com/watch?v=H_KovR7bcn8.

However, there is a certain, but easy to work with condition when creating a custom prediction serializer. Fish-Networking modifies your prediction data types to include extra information; these changes will not be visible to you.

To make your custom serializer support your prediction data type be sure to add public uint Generated___Tick to your prediction data type, and include it within your serializer.

public struct MoveData
{
    public uint Generated___Tick; //Add this field.
    public Vector3 Direction;
}

//Example of custom writer and reader
public static void WriteMoveData(this Writer writer, MoveData value)
{
    writer.WriteUInt32(value.Generated___Tick, AutoPackType.Unpacked);
    writer.WriteVector3(value.Direction);
}

public static MoveData ReadMoveData(this Reader reader)
{
    MoveData md = new MoveData()
    {
        Generated___Tick = reader.ReadUInt32(AutoPackType.Unpacked),
        Direction = reader.ReadVector3()
    };
}

Last updated