Let’s just say I’ve got a script something like this:
def main(): cont = bge.logic.getCurrentController() own = cont.owner x = 0 hit = cont.sensors['Collision'] bounce = cont.actuators['Motion'] if hit.positive and x<5: cont.activate(bounce) x = x + 1 else: cont.deactivate(bounce) main()
So what I’m trying to do is get it to stop after five bounces. (duh), but, Of course, you see the problem. It keeps making x = 0. If I get rid of the x = 0, then I’m referencing it before assigning it, and i’ll have problems. So, what’s a way to solve this?
(Other than using a global variable or something - there’s gotta be a better way than that.)
All advice is welcome, simplest solutions preferred.