isInView() accuracy?

Ive made a lensNode which I attach to enemie’s heads and use a task which checks if the player isInView()of the lenseNode so the enemies would spot me ad attack if I’m in their view. This seemed like a good way to use lensNode’s isInview(), but it seems very inaccurate in practice. isInView seems to return positive result only when the node is exactly in the middle of the lens.

Of course I could always just use Panda’s collision detectiona and replace the lensNode with a collisionPolygon, but I’m curious why this method gives such poor results.

LensNode.isInView() tests whether a given 3-D point is within the lens’s frustum. It’s perfectly precise for that point; how precise it is for your enemy’s head depends on how closely the point you choose represents the position of your enemy’s head.

It’s also possible to make a mistake and fail to convert the point in question into the LensNode’s coordinate space, which will tend to make the result appear inaccurate.



EDIT: OK, do you mean isInView(mynode.getPos(lensnp))?

The problem seemed to be caused when the player was pretty close to the enemy. I set a near distance for the lens and moved it back and it seems to work perfectly now.

However, when I didnt use setNear, isInView didnt spot the player even when you could tell with a naked eye that the player was in the lens “volume”