PDA

View Full Version : Holding Objects


betancourtb82
08-16-2006, 01:33 PM
I was wondering if anyone can help me out. I have an avatar array and I would like for each avatar to hold one weapon using the GetWeapon() function. I was wondering if it would be possible to, on a mouse click, have the avatars change their weapons (i.e. randomize which avatar is holding which weapon. I have included my code for the avatar array and the GetWeapon() function.
def GetWeapon(avatar,number):
global link
if number == 0:
#weapons to use
gunlink = viz.add(viz.GROUP) #for gun
gun = gunlink.add('M16M203.WRL')
avatar.gun = gun
gun.scale(.0005,.0005,.0005)
gunlink.link(hand)
elif number == 1:
phonelink = viz.add(viz.GROUP) #for phone
phone = phonelink.add('C:\Program Files\Vizard25\resources/phone.3ds')
avatar.phone = phone
phone.scale(1.5,1.5,1.5)
phone.rotate(-90,0,-90)
phone.translate(0,0.03,0.02)
phonelink.link(hand)
else:
cameralink = viz.add(viz.GROUP) #for camera
camera = cameralink.add('camera.WRL')
avatar.camera = camera
camera.scale(.0005,.0005,.0005)
camera.translate(0,-.25,.17)
camera.rotate(180)
cameralink.link(neck)
for x in range(0,3):
if x == 0:
male = viz.add(people[0])
# male.scale(.10,.10,.10)
male.face(faces[0])
hand = male.getbone('skel_HandRF')
neck = male.getbone('skel_Neck')
GetWeapon(male,0)
#phonelink.link(hand)
male.tag = 0
male.threatening = TRUE
male.appearance = 0
male.facepic = 0
elif x == 1:
male = viz.add(people[1])
male.scale(.11,.11,.11)
hand = male.getbone('skel_HandRF')
neck = male.getbone('skel_Neck')
GetWeapon(male,1)
#cameralink.link(neck)
male.tag = 1
male.threatening = FALSE
male.appearance = 0
male.facepic = 0
elif x ==2:
male = viz.add(people[2])
male.scale(.11,.11,.11)
hand = male.getbone('skel_HandRF')
neck = male.getbone('skel_Neck')
GetWeapon(male,0)
#gunlink.link(hand)
#male.face(faces[1])
male.tag = 2
male.threatening = FALSE
male.appearance = 0
male.facepic = 0
male.translate(3*x,-10,10)
male.rotate(180)
#Add the avatar to the waiting and lemming list
waitlist.append(male)
characters.append(male)