0 votes

I'm creating demo game for two player using PacketPeerUDP . i create server/client script and when i send String, it will sending/receiving messages to each other without any error.

Now When i tried to send [1,2,3] or ["p1:":"123"], i'm facing error Invalid call. Nonexistent function 'to_ascii' in base 'Array'.

Does there is anyway to send array using PacketPeerUDP?

asked Apr 3 in Engine by atopetrick (119 points)

1 Answer

+1 vote
Best answer

You can use to_json to convert the array into a string, send that and use parse_json on the receiving side to convert the string back to the array again.

https://docs.godotengine.org/en/3.1/classes/class_@gdscript.html?#class-gdscript-method-to-json

answered Apr 3 by wombatstampede (2,013 points)
selected Apr 3 by atopetrick

@wombatstampede thanks :)

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.