WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 09-18-2006, 12:02 PM
v-clizzin v-clizzin is offline
Member
 
Join Date: Sep 2006
Posts: 15
executing a turn in the middle of a walkto action

The goal of the program is to simulate repulsion by making an avatar walk around the world randomly unless it comes near another object (in this case, a lamp), at which point it turns around to reverse its path and walk away from the object. I am having trouble coding the turn and am not sure if there are better commands to use in the Viz library or if the entire way I'm setting up my timers to detect a repulsive object is wrong.

Here is the relevant code.
___________________________________________

# Starts the timers when the user presses '1'
def onkeydown(key):
if key == '1':
viz.starttimer(START_WALK, 6, viz.FOREVER) #Starts avatars walking to a random point, updates that random point every six seconds
viz.starttimer(START_REPULSION, 0.1, viz.FOREVER) #Checks for and enacts any repulsions every 0.1 seconds
# Timer function
def ontimer(num):
if num == START_WALK:
randWalk()
if num == START_REPULSION:
repulseObjects()
viz.callback(viz.KEYDOWN_EVENT, onkeydown)
viz.callback(viz.TIMER_EVENT, ontimer)

# Function: Makes each avatar in the environment walk to a random point
def randWalk():
for item in avatarList:
walk = vizact.walkto(getRandom(), 0, getRandom())
item.runAction(walk)
# Function: Causes the avatars to turn around if they get too close to the lamps
def repulseObjects():
for i in lampList: # Lamps are the 'repulsive objects' -- there are several in the world
for j in avatarList: # This is a list of all the avatar objects.
if distance(i.getPosition(), j.getPosition()) < 4:
# HERE IS WHERE A TURN WOULD BE EXECTED, BUT I DON'T KNOW WHAT CODE TO USE.
# I'VE TRIED:
# turnAround = vizact.spin(0,1,0,90,2)
# j.runAction(turnAround)
# I'VE TRIED:
# j.execute(3)
# I'VE TRIED:
# j.rotate(0,1,0,180)
# NONE OF THESE PRODUCE THE DESIRED EFFECT OF GETTING THE AVATAR TO TURN AROUND AND WALK AWAY FROM THE LAMP
# Notes on other functions:
# - getRandom() returns a float within a range of points
# - distance(list1, list2) returns the distance between two points; the lists are sets of coordinates
______________________________________

Any help on what commands are available to execute a turn-around and reverse path would be much appreciated. If there's a better way to set up the entire randomwalk/repulsionturnaround scheme, that would be great to hear about as well. Thanks a lot!

christopher lin

Last edited by v-clizzin; 09-18-2006 at 12:10 PM.
Reply With Quote
  #2  
Old 09-18-2006, 02:31 PM
Gladsomebeast Gladsomebeast is offline
Member
 
Join Date: Mar 2005
Location: Isla Vizta, CA
Posts: 397
What is the behevior of the Avatar when it should turn around?

Try stoping the currenly running actions with myAvatar.clearActions() then applying the new walkto action.
__________________
Paul Elliott
WorldViz LLC
Reply With Quote
Reply

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


All times are GMT -7. The time now is 12:17 PM.


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