the vector thing of the avatar

Hi there,

I am now trying to find a way when the avatar is nearing a location, a certain object (e.g. an panda) pops up. Now the object pops up when the avatar is in a certain sphere defined with reference to the object no matter which direction the avatar is facing. But I want the object pops up when the avatar is facing at the direction of the object not with the back of the avatar facing at the direction of the object.

So, Is there any method I can try to fix this out?


maybe something like this?

def testHit(node1,node2,threshold=15):  #node1 which looks for a target , node2 is the target
  dirVec = node1.getRelativePoint(node2,Vec3(0,0,0))
  dirVec = Vec3(dirVec[0],dirVec[1],dirVec[2])
  angle = dirVec.angleDeg(Vec3(1,0,0))
  if angle < threshold :
    print "hit at "+str(angle)+" degree!"
    return True
    print angle
    return False

small helper function i once wrote. dunno if there is something more convenient buildin. if node1 is facing node2 (within the given threshold in degrees) the function returns true. if not false.
you need to import

from pandac.PandaModules import Vec3

i hope you can make use of it:)

Thanks a lot