Thread: Collision
View Single Post
  #6  
Old 04-13-2009, 01:21 PM
Jeff Jeff is offline
WorldViz Team Member
 
Join Date: Aug 2008
Posts: 2,471
Here's an example with an avatar and a ball. You need to have collision shapes for both objects to have a collision. Your code did not have a collision shape for the avatar.
Code:
import viz
viz.go()

viz.phys.enable()

court = viz.add('court.ive')
court.collidePlane()

avatar=viz.add('vcc_male.cfg', pos = [0,0,3])
shape = avatar.collideBox()
shape.setDensity(10)

ball = viz.add('ball.wrl', pos = [0,0,7])
ball.collideSphere()

walk = vizact.walkTo([0,0,10])
vizact.onkeydown(' ', avatar.addAction, walk)
When you use
Code:
viz.collision(viz.ON)
that only turns on collision detection for the viewpoint.
If you want to stop the avatar from walking through the wall you could end the walkto action when the avatar is near the edge of the room
Reply With Quote