View Single Post
Old 03-10-2009, 12:45 PM
Jeff Jeff is offline
WorldViz Team Member
Join Date: Aug 2008
Posts: 2,466
Are you using viz.intersect to see whether or not the sensor is over the block?

You can continue to us viz.intersect to see whether or not the line drawn from below the sensor is still intersecting the block. If it is you don't need to do anything since the block has already been moved down. If it's not intersecting that object anymore the sensor has moved beyond it and you can reset the object's position.

if you're still using the vizintersect code from the other thread you started than you could change it to something like this.

currentBlock = None
def moveBlock():
	global currentBlock
	x,y,z = ball.getPosition()
	info = viz.intersect([x,y-1,z],[x,y-20,z])
	if info.valid and currentBlock == None:
		currentBlock = info.object
		currentBlock.setPosition([0,-10,0], viz.REL_LOCAL)
	elif not info.valid and currentBlock is not None:
		currentBlock.setPosition([0,10,0], viz.REL_LOCAL)
		currentBlock = None
Reply With Quote