Hey guys im making a game where as the character moves along a grid. I was using The motion actuator set to a value of 2, did the trick perfectly. But now i want to make a script so that my logic bricks wouldnt look like a huge disaster. I want to make things small and organized. Ive been trying for hours now to get this script to work. Here is what i did so far.
import GameLogic as GL
cont = GL.getCurrentController()
owner = cont.owner
scene = GL.getCurrentScene()
objList = scene.getObjectList()
loc = objList[“OBPlayer1”].position
W = cont.sensors[“W”]
loc
Y = 0
Z = 0
if W.positive:
owner.position = (+ 2,Y,Z)
#PROBLEM: This script makes the character move once, and thats it…it doesnt continue
But It Will not Be Able to rotate … look at this script if it can be of help for rotations
with this script you can use a single sensor …
must be a keyboard, and “all key” selected (preferably selected “pulse mode TRUE”)
shame That only works one button at a time … argh …
import bge
c = bge.logic.getCurrentController ()
o = c.owner
key = 0
s=c.sensors[“Keyboard”]
if s.positive:
key = s.events [0] [0] # events recorded numbers (eg 116…114)
# Corresponding to the keys of the keyboard
if key == 146: # up
o.linearVelocity [1] =- 5
if key == 144: # back
o.linearVelocity [1] = 2
if key == 143: # left
o.applyRotation ([0,0,0.02])
if key == 145: # right
o.applyRotation ([0,0, -0.02])
print (key)
hello
PS: for the linear Velocity the object must be “dinamics”