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()) self.picker.traverse(self.environ) if self.pq.getNumEntries() > 0: self.pq.sortEntries() self.placement = self.pq.getEntry(0).getSurfacePoint(self.environ) self.mousePointer.setPos(self.placement) self.mousePointer.setZ(50) self.model.lookAt(self.mousePointer) self.model.setP(0) self.model.setH(self.model.getH()+180) self.pq.clearEntries()
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.