WorldViz User Forum

WorldViz User Forum (https://forum.worldviz.com/index.php)
-   Vizard (https://forum.worldviz.com/forumdisplay.php?f=17)
-   -   Player - avatar distance (https://forum.worldviz.com/showthread.php?t=4715)

bzyqo 08-07-2013 06:24 AM

Player - avatar distance
 
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:
Code:

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 !!


All times are GMT -7. The time now is 04:48 PM.

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