![]() |
|
#1
|
|||
|
|||
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' Code:
print info.object.tag,'got shot' |
#2
|
|||
|
|||
![]()
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! |
#3
|
|||
|
|||
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 |
#4
|
|||
|
|||
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) |
#5
|
|||
|
|||
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 |
#6
|
|||
|
|||
Thank you, worked GREAT
|
![]() |
Thread Tools | |
Display Modes | Rate This Thread |
|
|