WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Link footsteps to arrow keys (https://forum.worldviz.com/showthread.php?t=5308)

BSUGeek 03-16-2015 06:25 AM

Link footsteps to arrow keys
 
Hi i'm trying to link the footsteps sound to when I use the arrow keys. I want the sound to play whenever the up,down,left, or right keys are pressed and to stop whenever none of them are pressed. how would i do that? thanks

Jeff 03-17-2015 01:05 AM

You can register callback functions with vizact.onkeydown and vizact.onkeyup to start and stop the sounds:

Code:

import viz
import vizact

viz.go()

viz.addChild('piazza.osgb')
avatar = viz.addAvatar('vcc_male2.cfg',pos=[0,0,6],euler=[180,0,0])
avatar.state(1)

def avatarWalk():
        avatar.playsound('footsteps.wav',viz.LOOP)
        avatar.state(2)
       
vizact.onkeydown(viz.KEY_DOWN,avatarWalk)

def avatarStop():
        avatar.playsound('footsteps.wav',viz.PAUSE)
        avatar.state(1)
       
vizact.onkeyup(viz.KEY_DOWN,avatarStop)



All times are GMT -7. The time now is 03:10 AM.

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