View Single Post
  #2  
Old 05-24-2010, 11:48 AM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
I'm not sure what's wrong without seeing more of the script. In the following example viz.COLLIDE_NOTIFY is enabled on the ball. When the ball collides with another object it will generate the collision event and show up as obj1 in the callback function. The object it collides with will be obj2.

Code:
import viz
viz.go()

viz.phys.enable() 

ground = viz.add('tut_ground.wrl') 
ground.collidePlane()   

ball = viz.add('ball.wrl',pos=(0,1.8,6)) 
ballPhys = ball.collideSphere(bounce=1.5)
ball.enable(viz.COLLIDE_NOTIFY)

def onCollide(e):
	if e.obj1 == ball:
		print 'ball collision'
	if e.obj2 == ground:
		print 'ground collision'
		
viz.callback( viz.COLLIDE_BEGIN_EVENT, onCollide )
Reply With Quote