I recently started learning python, and i now want to apply it to blender.
I looked for tutorials, but everyone i found was using depreciated code.
I have attempted to update this code (from a SageDread video on youtube).
It is now telling me:
Python script error - object 'player', controller 'code#CONTR#1': Traceback (most recent call last): File "movement.py", line 3, in <module> cont = bge.getCurrentController() NameError: name 'bge' is not defined
How can i fix it?
(my current code is below)
from bge import logic cont = bge.logic.getCurrentController() own = cont.owner #declare sensors forward = cont.sensors["forward"] left = cont.sensors["left"] right = cont.sensors["right"] backward = cont.sensor["backward"] #declare actuaters move = cont.actuators["movement"] #declare integer variables for movement FB = 0 LR = 0 speed = .05 #declare events if forward.positive(): FB = speed elif backward.positive(): FB = -speed if left.positive(): LR = speed elif right.positive(): LR = -speed move.setDLoc(FB,0.0,0.0,True) move.setDRot(0.0,0.0,LR,True) controller.activate(move)
Also, are their and good beginners tutorials focusing on the new API?