#1
|
|||
|
|||
random walk in piazza environment
hi,
I would like to generate a random walk actions for the avatar in the piazza environment. I want the avatar to walk around the environment by itself (without pressing any key) and to perform some actions when it sees a red sphere. I have tried to write some code, but the avatar is moving around an oval. I am really stuck .. I don't know how to do it. this is the code: Code:
import viz import viztask import vizact viz.go() viz.add('ground.osgb') avatar = viz.addAvatar('vcc_male2.cfg',pos=[0,0,9]) avatar.state(1) walkLeft = vizact.walkTo([2.5,0,9]) walkRight = vizact.walkTo([-2.5,0,9]) walkActions = viz.cycle([walkLeft,walkRight]) waitSpaceBar = viztask.waitKeyDown(' ') waitLeft = viztask.waitActionEnd(avatar,walkLeft) waitRight = viztask.waitActionEnd(avatar,walkRight) waitActions = viz.cycle([waitLeft,waitRight]) def walkAndStopTask(): yield waitSpaceBar while True: condition = waitSpaceBar walkAction = walkActions.next() waitAction = waitActions.next() while condition == waitSpaceBar: avatar.runAction(walkAction) d = yield viztask.waitAny([waitSpaceBar,waitAction]) condition = d.condition if condition == waitSpaceBar: avatar.clearActions() yield waitSpaceBar viztask.schedule(walkAndStopTask()) your support is highly appreciated |
Thread Tools | |
Display Modes | Rate This Thread |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
random coding | Saz | Vizard | 1 | 05-27-2010 05:44 PM |
random speed and associated coding | Saz | Vizard | 1 | 05-20-2010 04:03 AM |
Getting a mirror to work in any environment | Frank Verberne | Vizard | 5 | 03-27-2008 08:21 AM |
custom avatar random walk | krimble | Vizard | 2 | 03-20-2007 03:23 AM |
Random Seeds | Vygreif | Vizard | 1 | 04-27-2006 09:21 PM |