WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #4  
Old 02-06-2006, 09:45 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

This is very easy to do with Vizard. I've attached some sample code that will have the avatar walk to a random location every time the spacebar is pressed. Let me know if something isn't clear.
Code:
import viz
viz.go()

#Initialize environment
viz.clearcolor(viz.GRAY)
viz.add('tut_ground.wrl')
viz.move(0,5,-20)
viz.lookat(0,0,0)

#Create an avatar
avatar = viz.add('female.cfg')

#Create a walk action that will randomly select a location between (-5,-5) and (5,5)
RandomWalkAction = vizact.walkto(vizact.randfloat(-5,5),0,vizact.randfloat(-5,5))

#Add walk action to avatar when spacebar is pressed
vizact.onkeydown(' ',avatar.add,RandomWalkAction)
Reply With Quote
 


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


All times are GMT -7. The time now is 09:42 PM.


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