Update via UDP


I’m trying to update a camera position via UDP. I’m pretty new to this, and I know I’m doing something(s) totally wrong.

With the code listed below, nothing happens when I push UDP values… not even the print “got data” or “updated camera” stuff.

I know my UDP sending mechanism is working, because if I rearrange the code, I do get the print “got data” when I push UDP packets, but when I get success here, the model wont render at all! :confused:

I’m sure this would be an easy fix for an experienced user… I’d love your thoughts!

class RenderApp(ShowBase):
    def __init__(self):
        # set window properties
        wp = WindowProperties()
        wp.setTitle('SCREEN 1')

        # adjust camera for screen 1
        base.camList[0].setPos(0, -20, 0)
        base.camList[0].lookAt(0, 20, 0)
        # load model
        self.environ = self.loader.loadModel("model.egg")
        # setup networking
        host = ""
        port = 5432
        self.bufsize = 1024
        self.addr = (host,port)
        self.ssocket = socket(AF_INET, SOCK_DGRAM)
    def readData(self):
            data,addr = self.ssocket.recvfrom(self.bufsize)
            print "got data!"
            return data
            return 0
    def updateCameras(self, task):
        data = self.readData()
        if data:
            print "updated camera!"
app = RenderApp()

you need to add your task to the taskmanager. otherwise it will never run.

and you need to return a task continue , otherwise, the task will run exactly once and then ends.

Ah, I see… thank you for pointing me in the right direction! Adding the “return task.cont” and adding the task to “taskMgr.add” seemed to get things going.
Thanks again!