Binary serialization API

    Packet specification

    The packet is designed to be always padded to 4 bytes. All values are little-endian-encoded. All packets have a 4-byte header representing an integer, specifying the type of data:

    Following this is the actual packet contents, which varies for each type of packet. Note that this assumes Godot is compiled with single-precision floats, which is the default. If Godot was compiled with double-precision floats, the length of “Float” fields within data structures should be 8, and the offset should be . The “float” type itself always uses double precision.

    1:

    OffsetLenTypeDescription
    44Integer0 for False, 1 for True

    2: int

    OffsetLenTypeDescription
    48Integer64-bit signed integer

    3:

    OffsetLenTypeDescription
    44FloatIEE 754 32-Bits Float

    4: String

    OffsetLenTypeDescription
    44IntegerString length (in bytes)
    8XBytesUTF-8 encoded string

    This field is padded to 4 bytes.

    5:

    OffsetLenTypeDescription
    44FloatX coordinate
    84FloatY coordinate

    6: Rect2

    OffsetLenTypeDescription
    44FloatX coordinate
    84FloatY coordinate
    124FloatX size
    164FloatY size

    7:

    OffsetLenTypeDescription
    44FloatX coordinate
    84FloatY coordinate
    124FloatZ coordinate

    8: Transform2D

    OffsetLenTypeDescription
    44FloatThe X component of the X column vector, accessed via [0][0]
    84FloatThe Y component of the X column vector, accessed via [0][1]
    124FloatThe X component of the Y column vector, accessed via [1][0]
    164FloatThe Y component of the Y column vector, accessed via [1][1]
    204FloatThe X component of the origin vector, accessed via [2][0]
    244FloatThe Y component of the origin vector, accessed via [2][1]

    10:

    OffsetLenTypeDescription
    44FloatImaginary X
    84FloatImaginary Y
    124FloatImaginary Z
    164FloatReal W

    11: AABB

    OffsetLenTypeDescription
    44FloatX coordinate
    84FloatY coordinate
    124FloatZ coordinate
    164FloatX size
    204FloatY size
    244FloatZ size

    12:

    OffsetLenTypeDescription
    44FloatThe X component of the X column vector, accessed via [0][0]
    84FloatThe Y component of the X column vector, accessed via [0][1]
    124FloatThe Z component of the X column vector, accessed via [0][2]
    164FloatThe X component of the Y column vector, accessed via [1][0]
    204FloatThe Y component of the Y column vector, accessed via [1][1]
    244FloatThe Z component of the Y column vector, accessed via [1][2]
    284FloatThe X component of the Z column vector, accessed via [2][0]
    324FloatThe Y component of the Z column vector, accessed via [2][1]
    364FloatThe Z component of the Z column vector, accessed via [2][2]

    13: Transform

    OffsetLenTypeDescription
    44FloatThe X component of the X column vector, accessed via [0][0]
    84FloatThe Y component of the X column vector, accessed via [0][1]
    124FloatThe Z component of the X column vector, accessed via [0][2]
    164FloatThe X component of the Y column vector, accessed via [1][0]
    204FloatThe Y component of the Y column vector, accessed via [1][1]
    244FloatThe Z component of the Y column vector, accessed via [1][2]
    284FloatThe X component of the Z column vector, accessed via [2][0]
    324FloatThe Y component of the Z column vector, accessed via [2][1]
    364FloatThe Z component of the Z column vector, accessed via [2][2]
    404FloatThe X component of the origin vector, accessed via [3][0]
    444FloatThe Y component of the origin vector, accessed via [3][1]
    484FloatThe Z component of the origin vector, accessed via [3][2]

    14:

    OffsetLenTypeDescription
    44FloatRed (typically 0..1, can be above 1 for overbright colors)
    84FloatGreen (typically 0..1, can be above 1 for overbright colors)
    124FloatBlue (typically 0..1, can be above 1 for overbright colors)
    164FloatAlpha (0..1)

    15: NodePath

    OffsetLenTypeDescription
    44IntegerString length, or new format (val&0x80000000!=0 and NameCount=val&0x7FFFFFFF)

    For old format:

    OffsetLenTypeDescription
    8XBytesUTF-8 encoded string

    For new format:

    OffsetLenTypeDescription
    44IntegerSub-name count
    84IntegerFlags (absolute: val&1 != 0 )

    For each Name and Sub-Name

    Every name string is padded to 4 bytes.

    16: (unsupported)

    17: Object (unsupported)

    OffsetLenTypeDescription
    44Integerval&0x7FFFFFFF = elements, val&0x80000000 = shared (bool)

    Then what follows is, for amount of “elements”, pairs of key and value, one after the other, using this same format.

    19:

    OffsetLenTypeDescription
    44Integerval&0x7FFFFFFF = elements, val&0x80000000 = shared (bool)

    20: PoolByteArray

    OffsetLenTypeDescription
    44IntegerArray length (Bytes)
    8..8+length1ByteByte (0..255)

    The array data is padded to 4 bytes.

    21:

    OffsetLenTypeDescription
    44IntegerArray length (Integers)
    8..8+length*44Integer32-bit signed integer

    22: PoolRealArray

    OffsetLenTypeDescription
    44IntegerArray length (Floats)
    8..8+length*44Integer32-bits IEEE 754 float

    23:

    OffsetLenTypeDescription
    44IntegerArray length (Strings)

    For each String:

    OffsetLenTypeDescription
    X+04IntegerString length
    X+4XBytesUTF-8 encoded string

    Every string is padded to 4 bytes.

    24: PoolVector2Array

    OffsetLenTypeDescription
    44IntegerArray length
    8..8+length84FloatX coordinate
    8..12+length84FloatY coordinate

    25:

    26: PoolColorArray

    OffsetLenTypeDescription
    44IntegerArray length
    8..8+length164FloatRed (typically 0..1, can be above 1 for overbright colors)
    8..12+length164FloatGreen (typically 0..1, can be above 1 for overbright colors)
    8..16+length164FloatBlue (typically 0..1, can be above 1 for overbright colors)
    8..20+length164FloatAlpha (0..1)