PDA

View Full Version : Link footsteps to arrow keys


BSUGeek
03-16-2015, 06:25 AM
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:

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)