Attach a model to the mouse position

I want to modify the tunnel example and attach a model to the mouse cursor. I have a task setup to get the mouse’s X/Y position, but I’m not sure how to translate that to world space and set the model’s position to it.

Also, how do I prevent the mouse from going out of the window because that crashes the game.


I think I got it.

  def checkMousePos(self, task):
    md =
    #x = md.getX()
    #y = md.getY()
    if (base.mouseWatcherNode.hasMouse()):
      print str(x)+" is mouse X"
      print str(y)+" is mouse Y"
    return Task.cont

Seems to work well. I just need to work on some other stuff. If I have any problems about the ship/mouse stuff I’ll post here.

For my skybox I use a simple texture mapped sphere or cube in the form of a nodepath. I use this technique to insure that my camera is exactly in the center of the sphere/cube at all times (e.g. I can never reach the sky).