I am running this script on my BGE... I had issues receiving the socket information inside a while True loop. Then realised that the while was bugging the script.

I also tried to receive the information using a thread, but it didn't work.

So I made the following considering that the script will open the socket every frame of the game but it still crashes my blender.

import bge 
import socket
import pickle

UDP_IP = ""
UDP_PORT = 5005

sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
sock.bind((UDP_IP, UDP_PORT))

data, addr = sock.recvfrom(1024)
movement = pickle.loads(data)

controller = bge.logic.getCurrentController()
own = controller.owner


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.