WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 12-15-2013, 09:37 AM
maya maya is offline
Member
 
Join Date: Nov 2013
Location: United Arab Emirates
Posts: 21
Unhappy 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
Reply With Quote
 

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
random coding Saz Vizard 1 05-27-2010 06:44 PM
random speed and associated coding Saz Vizard 1 05-20-2010 05:03 AM
Getting a mirror to work in any environment Frank Verberne Vizard 5 03-27-2008 09:21 AM
custom avatar random walk krimble Vizard 2 03-20-2007 04:23 AM
Random Seeds Vygreif Vizard 1 04-27-2006 10:21 PM


All times are GMT -7. The time now is 05:57 AM.


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