View Single Post
  #4  
Old 12-11-2015, 09:03 AM
Erikvdb Erikvdb is offline
Member
 
Join Date: May 2013
Posts: 63
Probably not the most elegant solution, but one that's short and working:
Code:
wind = False
tree.runAction(vizact.animation(1))

def onKeyDown(key):
    global wind
    if key == " ":
        wind = True
        tree.runAction(vizact.animation(3))

def onActionEnd(e):
    global wind
    if e.object is tree:
        if wind:
            wind = False
        else:
            anim = vizact.animation(random.choice([1,5,6]))
            tree.runAction(anim)

viz.callback(viz.ACTION_END_EVENT,onActionEnd)
viz.callback(viz.KEYDOWN_EVENT, onKeyDown)
Reply With Quote