model as a mouse cursor?

hi all,

I’m new to Panda3D and have a question about the mouse cursor.

Right now I try to make a FPS kinda game only it is a bit different.
I can move the camera with the keyboard (forward,backward,rotate, left,right) but now I want to use the mouse cursor for pointing at the ‘monsters’.

the mouse has completly free movement and the camera is not moving with the mouse.

my question is how can I have a crosshair(2d) instead of a mouspointer?
I found some pieces of code on the website but it’s not working…
I looked at the airblade code but I can’t find the piece I need.

Can somebody please help! thanks so much

(sorry, my english is maybe a bit off)

I believe there were already some topics on the forums about that sort of problem.
What you have to do is:
First hide the mouse cursor, create an onscreenimage, have it repositioned every frame at the mouse position.

There’s actually a method right in MouseWatcher called setGeometry to do this.

thanks guys!

I figured it out with your help, and some code snippets from the forum. but now I run into a problem. the model is not centered.

the red mark is the position of the mouse right now and the blue on is what I want to achieve…

this is the code i’m using:

crosshair = loader.loadModel('models/boxegg') 
crosshairTexture = loader.loadTexture("maps/crosshair.png")
dummyNP = render2d.attachNewNode('crosshair') 

and again sorry for the stupid questions, i’m really a noob :frowning:


Just set the position of the crosshair node:

thank you so much!


that worked for me!
such a simple thing and I didin’t think of it :blush:

thanks again / dankje