![]() |
|
#1
|
|||
|
|||
|
Distance or position based event?
We're trying to play a sound when the viewpoint reaches a certain point in the virtual environment. Do we have to register a custom event to do this? Is there a way to use a loop without freezing the program?
|
|
#2
|
|||
|
|||
|
It seems like you simply want to run some code every frame. In that case you can register a timer function, which will be called every frame. Here is an example that plays a sound when the Z position of the view passes 3 meters:
Code:
import viz
viz.go()
viz.add('tut_ground.wrl')
def CheckView():
"""Plays a sound when Z position of view is greater than 3"""
x,y,z = viz.MainView.getPosition()
if z > 3:
# Play sound and unregister timer function
viz.playsound('elaugh1.wav')
return vizact.EventRemove
vizact.ontimer(0,CheckView)
|
![]() |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| writing joystick position to a data file | Saz | Vizard | 3 | 12-17-2008 06:18 AM |
| default start position | erchrastil | Vizard | 2 | 06-23-2008 09:15 AM |
| position of html-file on screen | active_world | Vizard | 1 | 05-16-2008 08:24 PM |
| Avatar always returns in initial position | pattie | Vizard | 2 | 08-31-2006 09:15 PM |
| Get position data in an own little program | Researcher | Precision Position Tracker (PPT) | 2 | 02-01-2006 03:55 AM |