#How to store array of custom objects as godot primitive

1 messages · Page 1 of 1 (latest)

trail crow
#

Heya folks, I'm trying to pass an array of custom objects through an RPC call. I know I can transform each into a byte array, but I don't think RPC calls support multidimensional byte arrays. What are my options?

sturdy holly
#

If you already have a serialize for a byte array of the objects, the easiest is to just use
var data: Array[PackedByteArray] = []
for obj in MyObjects:
data.add(obj.serialize())

or something like that

#

So you can send a typed array of PackedByteArrays

#

It's not the most optimal, but it works

#

Just deserialize them and create the objects on the other end

#

(This is all assuming a homogeneous array and one type of object per rpc)

#

(Otherwise you need to serialize the object type as well)