WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Arrays (https://forum.worldviz.com/showthread.php?t=511)

betancourtb82 02-20-2006 12:50 PM

More Animations
 
I am still relatively new to Vizard and had a question on arrays. I have created (with some help from farshizzo) an array that holds 5 avatars.

Code:

#Create six avatars
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.translate(newX,0,newZ)
        male.rotate(180,0,0)
        avatars.append(male) #Save avatar in list
#        walkAvatar(_avatars)
walk = male.walkto(0,0,-10.5,1,0,2)

I was able to make each of these avatars walk in a separate way, but now I want to make them "die" once I click on them. I have a shoot bullet animation so it looks like they are getting shot, but in actuality they are just being clicked on. The suggestion made by Farshizzo on the avatar animations thread worked for a stationary avatar but once they start moving using the following code, they get up even after I "shoot" them. Any suggestions?:
Code:

def mytimer(num):
       
        if num == ANIMATION:
               
                #Calculate elapsed time since last update
                elapsed = viz.elapsed()
               
                #Update each active ball
                for bullet in bullets:
                        if bullet.active:
                                #Move the ball and check if it has collided with any objects
                                MoveBullet(bullet,elapsed)
               
                #Update the crosshair position
                crosshair.translate(viz.mousepos()+[0])
               
        elif num == START_AVATAR:
                global nextAvatar
                #Get the next available duck and start it
                avatar = avatars[nextAvatar]
                walkAvatar(avatar)
                nextAvatar = (nextAvatar + 1) % NUM_AVATARS
                viz.starttimer(START_AVATAR,TIME_BETWEEN_AVATARS)

##Start a timer which starts the next available avatar
viz.starttimer(START_AVATAR,0.01)

Thanks

betancourtb82 02-21-2006 10:40 AM

Problem Solved, on to the next one
 
Ok, I solve the problem I was having yesterday by adding a
Code:

clear(viz.ALL)
clear(viz.CURRENT_ACTION)

Now my next question would be, how can I take the fallen avatar out of the scene and reset him/her to a new avatar, i.e. how can I remove him from the array and place another one in the array.

Thanks

farshizzo 02-21-2006 11:30 AM

Hi,

The following will remove an avatar from the array:
Code:

avatars.remove(male)
Then you would use the append command to add a new avatar:
Code:

avatars.append(male)


All times are GMT -7. The time now is 11:19 PM.

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