I am having trouble with playing an IPO. My goal is to press the right-arrow, and have my tire turn to mimic steering. I would like it to play it as a flipper, so that when the button is released, the animation doesn’t finish, but returns to frame 1. Essentially, I would like to get the same effect as if I wired it as below, but instead write it completely in Python:
The problem I am having is this: When I press the right arrow, senright returns positive, and my if statement executes, and the ipo doesn’t play until I release the right arrow. I have tried many different things to fix this, and searched the forums, and I suspect that I need to use something like setUsePosPulseMode() or setPosFrequency, but i can’t seem to get that to work either. Does anyone have any suggestions?
Also, the game kit documentation says that there are 6 ipo play types; does accessing the list begin with setType(0) or setType(1)? Thanks for helping with these two questions.
-Brian
###############################################################
###############STOPPED#########################################
if dirX == 0 and dirY == 0:
forward = 1
print "Stopped", orient
senup.setKey(146) #up-arrow
sendown.setKey(144) #down-arrow
senleft.setKey(143) #left-arrow
senright.setKey(145) #right-arrow
if senup.isPositive():
move.setLinearVelocity(1, 0, 0, 1)
tfr.setDRot(velocity/10, 0, 0, 1)
tfl.setDRot(velocity/10, 0, 0, 1)
tbr.setDRot(velocity/10, 0, 0, 1)
tbl.setDRot(velocity/10, 0, 0, 1)
GameLogic.addActiveActuator(move, 1)
GameLogic.addActiveActuator(tfr, 1)
GameLogic.addActiveActuator(tfl, 1)
GameLogic.addActiveActuator(tbr, 1)
GameLogic.addActiveActuator(tbl, 1)
elif sendown.isPositive():
print "sensor down is pressed"
forward = 0
backward = 1
move.setLinearVelocity(-1, 0, 0, 1)
tfr.setDRot(-velocity/10, 0, 0, 1)
tfl.setDRot(-velocity/10, 0, 0, 1)
tbr.setDRot(-velocity/10, 0, 0, 1)
tbl.setDRot(-velocity/10, 0, 0, 1)
GameLogic.addActiveActuator(move, 1)
GameLogic.addActiveActuator(tfr, 1)
GameLogic.addActiveActuator(tfl, 1)
GameLogic.addActiveActuator(tbr, 1)
GameLogic.addActiveActuator(tbl, 1)
elif senright.isPositive():
print "sensor right is pressed"
tfrsteer.setType(3)
tfrsteer.setStart(1)
tfrsteer.setEnd(16)
# tfrsteer.setDRot(0, 0.1, 0, 1)
# tflsteer.setDRot(0, 0.1, 0, 1)
GameLogic.addActiveActuator(tfrsteer, 1)
GameLogic.addActiveActuator(tflsteer, 1)