Quote:
Originally Posted by sportykourty
Wow thanks! that's really helpful. So if I want the health to continue to drop until I exit the proximity would i just do a While(true) loop?
|
No, entering and exiting a proximity are two separate events. Use them to toggle a state that you can check for in the general update loop.
Code:
health = 100
healthloss = False
def onEnter(e):
if e.target == target:
healthloss = True
def onExit(e):
if e.target == target:
healthloss = False
manager.onEnter(sensor, onEnter)
manager.onExit(sensor, onExit)
# Demo
def update():
if healthloss:
health -= 2 * viz.elapsed()