WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #5  
Old 04-15-2015, 02:54 AM
Erikvdb Erikvdb is offline
Member
 
Join Date: May 2013
Posts: 63
Quote:
Originally Posted by sportykourty View Post
So I was trying to incorporate the previous code but I'm stuck. does my sensor and target have to be in the same manager? I'm not really sure what I'm doing wrong but the function never executes.
Yes, all targets and sensors that interact with each other have to be assigned to the same manager.

Here's a complete code example:
Code:
import viz
import vizact
import vizproximity

# Physical Objects
ball = viz.addChild('beachball.osgb',pos=[-1,0.2,0])
avatar = viz.addAvatar('vcc_male2.cfg',pos=[1,0,0])
avatar.setEuler([180,0,0])
avatar.state(5)

# Proximity Management
manager = vizproximity.Manager()
manager.setDebug(viz.ON)

sensor = vizproximity.Sensor(vizproximity.Sphere(0.5, center=[0,0,0]), ball)
manager.addSensor(sensor)

target = vizproximity.Target(avatar)
manager.addTarget(target)

def healthLoss(e):
	if e.target == target:
		print "Sensor Entered"
		
manager.onEnter(sensor, healthLoss)

# Demo
def update():
	if viz.key.isDown(viz.KEY_LEFT):
		avatar.setPosition([-2*viz.elapsed(),0,0],viz.REL_GLOBAL)
	elif viz.key.isDown(viz.KEY_RIGHT):
		avatar.setPosition([2*viz.elapsed(),0,0],viz.REL_GLOBAL)
		
vizact.ontimer(0,update)

viz.MainView.setPosition([0,1,-4])
viz.go()
Use arrow keys to move the avatar to the ball.
Created in Vizard 4.
Reply With Quote
 


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Unexpected Avatar lookAt() behavior when using yield statements chris2307 Vizard 2 12-17-2013 03:58 AM
Avatar & Motion Capture Interface Angie Vizard 1 08-05-2010 07:17 PM
Collision of an avatar with a quad Frank Verberne Vizard 8 06-04-2008 10:44 AM
Looking through the eyes of an avatar Frank Verberne Vizard 2 04-01-2008 06:52 AM
How to make avatar's eyes to blink when speaking michelcm3 Vizard 12 01-15-2008 09:48 AM


All times are GMT -7. The time now is 05:38 PM.


Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2025, vBulletin Solutions, Inc.
Copyright 2002-2023 WorldViz LLC