#1
|
|||
|
|||
Avatar walk
I was wondering if you could help me with this problem. I think it's more of a mathematical problem but I think it applies to programming. I need for avatars to appear from all directions instead of just in front of the person participating in the experiment. I can't seem to figure out how to set up my x,y,z to have this occur. We want avatars to appear from all directions and have the user actually have to look around to see where they are coming from.
Here is what I have so far: Code:
for i in range(NUM_AVATARS): newX = -math.cos(-2*i+15) * 2 newZ = math.sin(45*i) * 10 male = viz.add('male.cfg') male.translate(newX,-10,newZ) male.rotate(180,0,0) avatars.append(male) #Save avatar in list Code:
def mytimer(num): global avatars 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) elif num == START_AVATAR: global nextAvatar #Get the next available avatar and start it avatar = avatars[nextAvatar] #favatar = favatars[nextAvatar] walkAvatar(avatar) #walkAvatar(favatar) nextAvatar = (nextAvatar + 1) % NUM_AVATARS viz.starttimer(START_AVATAR,TIME_BETWEEN_AVATARS) #Restore next available avatar vizact.onkeydown(' ',RestoreAvatar) #Shoot a ball whenever left mousebutton is clicked vizact.onmousedown(viz.MOUSEBUTTON_LEFT,shootBullet) #Create callbacks for timer events viz.callback(viz.TIMER_EVENT,mytimer) Last edited by betancourtb82; 03-15-2006 at 11:06 AM. |
#2
|
|||
|
|||
Hi,
Can you be more specific on where you want them to appear. Can you just select random coordinates within a certain range? |
#3
|
|||
|
|||
I would like for them to appear within a radius of the subject. I want them to appear in front, to the left and right and behind the subject and certain intervals. They don't have to be random to the programmer, but appear random to the user. In other words, the order they appear is not important. So, basically, what I need to do is have them appear around the user coming in from all directions.
|
#4
|
|||
|
|||
Hi,
The following code will compute a random position within a certain radius. Code:
#Get random direction angle = viz.radians(vizmat.GetRandom(0,360)) #Get random radius between 5 and 10 radius = vizmat.GetRandom(5,10) #Compute position x = math.sin(angle) * radius z = math.cos(angle) * radius |
#5
|
|||
|
|||
Thanks! That really
|
#6
|
|||
|
|||
Thanks! That really helped out
|
Thread Tools | |
Display Modes | Rate This Thread |
|
|