View Single Post
  #2  
Old 01-02-2011, 01:49 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
You can add a function that's called every frame that checks the distance between the object and the center of the circle. Depending on the distance value you'll know whether the object is inside or outside of the circle:
Code:
import viz
import vizact
import vizmat

viz.go()

CIRCLE_CENTER = [0,0,5]
CIRCLE_RADIUS = 2

court = viz.addChild('court.ive')
avatar = viz.addAvatar('vcc_male.cfg')

text = viz.addText('',parent=viz.SCREEN)
text.setPosition(0.3,0.8)
text.color(viz.RED)

walk = vizact.walkTo([0,0,10])
avatar.addAction(walk)

def collisionCheck():
	distance = vizmat.Distance(CIRCLE_CENTER,avatar.getPosition())
	if distance > CIRCLE_RADIUS:
		text.message('Outside circle')
	else:
		text.message('Inside circle')
	
vizact.ontimer(0,collisionCheck)
Reply With Quote