PDA

View Full Version : Player - avatar distance


bzyqo
08-07-2013, 06:24 AM
Guys I have a small problem. Basically I would like to calculate the distance between the avatar and the main camera (player) in the scene. Do anyone have some kind of idea how to do that?

Jeff
08-07-2013, 02:29 PM
You can use the vizmat.Distance command to calculate the distance between two points:

import viz
import vizmat
import vizact
viz.go()

avatar = viz.addAvatar('vcc_male2.cfg',pos=[0,0,5],euler=[180,0,0])
head = avatar.getBone('Bip01 Head')

def printDistance():
avatarPos = head.getPosition(viz.ABS_GLOBAL)
viewPos = viz.MainView.getPosition()
distance = vizmat.Distance(avatarPos,viewPos)
print distance

vizact.ontimer(1,printDistance)

bzyqo
08-09-2013, 10:16 AM
Thank you so so much !!