View Single Post
  #7  
Old 04-21-2015, 12:53 AM
Erikvdb Erikvdb is offline
Member
 
Join Date: May 2013
Posts: 63
Quote:
Originally Posted by sportykourty View Post
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()
Reply With Quote