WorldViz User Forum  

Go Back   WorldViz User Forum > Vizard

Reply
 
Thread Tools Rate Thread Display Modes
  #1  
Old 05-04-2006, 10:48 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

I'm not sure exactly what you are asking here. You just need a way to identify each avatar when they get shot? Just add some tag to each avatar when you create/restore it.
Code:
male.tag = 'avatar 1 with object 2'
Then when they get shot just look up the tag:
Code:
print info.object.tag,'got shot'
Reply With Quote
  #2  
Old 05-04-2006, 11:00 AM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Talking

PERFECT! Thanks for the help. Can I do the same thing with the object they are holding? Since the object is a different array that's merely linked to this one, how do I identify the object in hand? Basically if it's a gun or a cell phone I just need to specify that it's "non-threatening". If it's a gun then i have to specify that it's "threatening".

Thanks again!
Reply With Quote
  #3  
Old 05-04-2006, 11:07 AM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

In python, you can add as many attributes to an object as you wish. So to determine if an object is "threatening" simply give it an attribute which says so.
Code:
donut = viz.add('donut.wrl')
donut.isThreatening = False
donut.isDelicious = True

gun = viz.add('gun.wrl')
gun.isThreatening = True
gun.isDelicious = False
Reply With Quote
  #4  
Old 05-04-2006, 12:35 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Ok, I understand that part, but my problem is how do I let the program know that the avatar is holding that object. In the MoveBullet function shown above, I identify the avatar "attribute" as info.object.tag, but how do I do that with the object they are holding. Can I do something like info.object.tag.linkbone to identify each object of each avatar?

Code:
for x in range(0,3):
 if x == 0:
  male = viz.add(people[0]) 
  male.scale(.1,.1,.1)
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[0])
  myphone.scale(.0005,.0005,.0005)
  male.linkbone(link,'skel_HandR')
  male.tag = 0
  myphone.threatening = TRUE
  
 elif x == 1:
  male = viz.add(people[1])
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[1])
  myphone.scale(.0005,.0005,.0005)
  myphone.translate(0,-.25,.17)
  myphone.rotate(180)
  male.linkbone(link,'skel_Neck')
  male.tag = 1
  myphone.threatening = FALSE
 elif x ==2:
  male = viz.add(people[2])
  link = viz.add(viz.GROUP) 
  myphone = link.add(objects[2])
  myphone.scale(.0008,.0008,.0008)
  myphone.rotate(66.51,151.49,86.01)
  myphone.translate(-0.02,0.04,0.02)
  male.linkbone(link,'skel_HandRF')
  male.tag = 2
  myphone.threatening = FALSE
 male.translate(3*x,-10,10)
 male.rotate(180)
 #Add the avatar to the waiting and lemming list
 waitlist.append(male)
 characters.append(male)
Reply With Quote
  #5  
Old 05-04-2006, 12:55 PM
farshizzo farshizzo is offline
WorldViz Team Member
 
Join Date: Mar 2003
Posts: 2,849
Hi,

As I already mentioned, you can add any attribute to an object. So just add an attribute to each avatar which contains a list of the objects it is holding.
Code:
male.holding = [gun,phone,bowlingBall]
.
.
.

print 'Avatar is holding',info.object.holding
Reply With Quote
  #6  
Old 05-04-2006, 02:13 PM
betancourtb82 betancourtb82 is offline
Member
 
Join Date: Jan 2006
Posts: 103
Thank you, worked GREAT
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 04:46 PM.


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