WorldViz User Forum

WorldViz User Forum (
-   Vizard (
-   -   Distance or position based event? (

vissimutah 08-25-2009 11:38 AM

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?

farshizzo 08-25-2009 12:26 PM

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:

import viz


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
                return vizact.EventRemove

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

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