WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #24  
Old 03-01-2006, 12:48 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Similar Question

I am also trying to remove items using object.remove. First, I add 4 avatars (NUM_AVATARS) to an array. They will be removed as they are shot by the user. The problem I'm having is how to add them again if one of them is taken off. I have the 4 avatars, but I would like for them to be added to the array once they have been shot (causing a remove). I was thinking of saying something like "if the number of array elements is not 4, add another avatar". Can I do this and if so, how. Also, would this be the best way to go about doing this. Here is what I have so far.

Code:
Create avatars coming from the front
for i in range(NUM_AVATARS):
	newX = -math.cos(-2*i+15) * 2
	newZ = math.sin(i^2+1) * 2	
	male = viz.add('male.cfg')
	#male.face(facepic)
	male.translate(newX,-10,newZ)
	male.rotate(90,-10,0)
	#we might be able to use this type of declaration when we need to decide who is safe to shoot and who isn't
	male.SafeIndicator = 1						
	avatars.append(male) #Save avatar in list
	print "avatar indicator is", male.SafeIndicator	

#Two differnt options for moving avatars
#Create a walk action that will randomly select a location between (-5,-5) and (5,5)
RandomWalkAction = vizact.walkto(vizact.randfloat(-5,5),court,vizact.randfloat(-10,5))
#Create a walk action that will randomly select a location between (-5,-5) and (5,5)
WalkForever = vizact.sequence(vizact.walkto(vizact.randfloat(-2,5),0,vizact.randfloat(-10,5)),viz.FOREVER)

def walkAvatar(starter):
	global court
	walk = starter.walkto(0,court,-10.5,1,0,2)
	#Clear all the avatar's actions, reposition it, and start the walk action
	starter.clear(viz.ALL)
#	starter.translate(duckBeginPos)
#	starter.rotate(duckBeginOri)
	starter.act(walk)
	#Add walk action to avatar
	#starter.add(WalkForever)

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

if avatars[0] or avatars[1] or avatars[2] or avatars[3] == 0:
	print 'empty avatar at avatar'
	avatars.append(male)
	walkAvatar(male)
	print 'avatar added'
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 03:49 AM.


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