Guest User

Python_Shot

a guest
Jan 14th, 2020
74
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import math
  2. import bge
  3. import serial
  4. import time
  5. from bge import logic
  6. from bge import events
  7.  
  8. porta = serial.Serial('COM3', 9600, timeout = 0.05)
  9.  
  10. def Start(controller):
  11.     own = controller.owner
  12.     print("inicio...")
  13.  
  14. def Update(controller):
  15.     scene = bge.logic.getCurrentScene()
  16.     obj = scene.objects['Empty']
  17.     if(porta.inWaiting() > 0):
  18.         data = porta.readline().decode('utf-8')
  19.         time.sleep(0.02)
  20.         letra = data[0]
  21.         print(letra)
  22.         if letra == 'd':
  23. actuator = controller.actuators['ActuatorName']
  24. controller.activate(actuator)
  25. data=""
RAW Paste Data