Okay I’ve gotten help before from y’all, so I’ll keep asking my questions. If I’m not being specific enough or there’s something causing my questions to be ignored, please by all means tell me.
I’m trying to make it so that if you tap the w a s d keys you get a slight correction in that direction. If you hold them down though it’ll roll or pitch the vehicle using a faster speed.
The print statements are there to see what’s going on, I haven’t been able to make “above” return a value of 1 however, though the “below” one seems to.
Here’s the code I have:
import GameLogic
controller = GameLogic.getCurrentController()
owner = controller.getOwner()
motion = controller.getActuator("actMotion")
fwd = controller.getSensor("fwd")
bwd = controller.getSensor("bwd")
left = controller.getSensor("left")
right = controller.getSensor("right")
engine = controller.getSensor("e_key")
xRotAction = 0
yRotAction = 0
mainSpeed = 0
linSpeed = 0.5
rotSpeed = 0.2
rotFastSpeed = 1
print ("above %i" % xRotAction)
if xRotAction == 1:
xrot = rotFastSpeed * (fwd.isPositive() - bwd.isPositive())
yrot = rotFastSpeed * (right.isPositive() - left.isPositive())
else:
xrot = rotSpeed * (fwd.isPositive() - bwd.isPositive())
yrot = rotSpeed * (right.isPositive() - left.isPositive())
if xrot or yrot != 0:
xRotAction += 1
yRotAction += 1
print ("below %i" % xRotAction)
motion.setAngularVelocity(xrot, yrot, 0, 1)
motion.setLinearVelocity(0,mainSpeed,0,1)
GameLogic.addActiveActuator(motion,True)
Thanks in advance.
-Stefan-