Input via socket

I’m new to Defold, please excuse if the answer is obvious, but I couldn’t find anything.

How could I create input (with permanent update of action.x, action.y for a start) from data received via network? I would like to experiment with hand position detected by YOLOv7, which comes as a stream of UDP packages. I found the examples for receiving data from network, but I somehow miss how I can trigger input events of a gameobject.

Many thanks!

I don’t know the best way to communicate with UDP through a socket.
It should be possible I guess.

For the input itself, there is no way to add input events from Lua.
I suggest that you call a function with the input coordinate: handle_input(x, y)

To make sure I understand, you mean, I shall save the x,y position somwhere, and in my functionupdate(self, dt) I call handle_input(x, y) to react on the changed coordinates?

Well, it depends on how you handle the data coming from the stream?
You still need to poll the data from the socket.
That might be a good place to call the handler.
But you could also save the info for later.

ok, I get it, then I will try out how to do the socket handling, and after this decide how to do the rest.
Any case, it sounds easy, which is great :slight_smile:

Thank you so much.

1 Like

If you need some help setting up the UDP socket in Defold you can take a look here:

(I haven’t worked with the code above in quite some time but it should be up to date and working still!)

this is where I will start from :grinning: very much look forward to dive deeper in Defold
Thank you!

2 Likes