model looking at mouse cursor

I’m struggling with having my character model lookAt() the mouse cursor. I have a snippit of code that works but only as long as the character model is not near the edges of the screen.
picker is my traverser
pq is my collision queue
pickerRay is a collisionRay
environ is the ground

if base.mouseWatcherNode.hasMouse():
mpos = base.mouseWatcherNode.getMouse()
self.pickerRay.setFromLens(base.camNode, mpos.getX(), mpos.getY())
if self.pq.getNumEntries() > 0:
	self.placement = 

I’m really facing two issuses at the moment. The first is the present code loses focus on the mouse when at the edges of the screen which is highly problematic. The second is I would like to find some way to stop using the traverser and queue to determine where the model should be looking as this can be memory intensive. I would appreciate any suggestions cause everything I’ve tried beyond this so far has not worked.

I remember in “Looking and gripping” sample Eve model always looks at cursor.

For some complicated case I would:

  1. project model position on the screen and find out its coordinates in 2D space of the camera,
  2. get mouse position,
  3. found out the rotation required to make model projection look at mouse,
  4. apply this rotation to the model.

To project your model on screen, you can use:

def nodeCoordIn2d(np):
    coord3d =,
    coord2d = Point2()
    base.camLens.project(coord3d, coord2d)
    coordInRender2d = Point3(coord2d[0], 0, coord2d[1])
    coordInAspect2d = aspect2d.getRelativePoint(render2d,
    return coordInAspect2d