Titles explains it. I’m making an FPS multiplayer shooter, so it’s pretty important for it to be full screen and for the cursor to be gone so you can infinitely look around, like in any normal FPS.
Is it possible, and if so, how would I go about doing that?
All you can do is make a config.prc and adjust the settings there:
# Somewhere in the code, preferably at the beginning
from panda3d.core import loadPrcFile, Filename
In the config.prc, replace “show-cursor false” with “cursor-hidden true”
It can also be done in code via the “WindowProperties” interface. This has the advantage of allowing you two switch back and forth–such as when moving between gameplay and a mouse-driven menu.
See this manual page for more information:
And see the API-page for “WindowProperties” for a list of features that it offers.
Hmm, that’s interesting.
How would I go about attaching the mouse movements to the hpr of the camera then?
You can use base.mouseWatcherNode.getMouse() to manipulate the mouse.
You can use the getMouse().getX() and getMouse().getY() for the x and y pos of the mouse (there is no z as it is 2d), and then calculate some maths according to your wish.
Or you can just do self.camera.lookAt(base.mouseWatcherNode.getMouse())
(I haven’t tried it though)
That’s generally done in code, I believe.
Alternatively to the mouseWatcherNode approach shown above, you can get the mouse-position by calling “getPointer(0)” on the window-object, like so:
mouseData = base.win.getPointer(0)
xPos = mouseData.getX()
(This interface is, I’ve recently learned, a little more accurate than the “mouseWatcherNode” method used above. However, it’s also a little more complicated to use.)
PS: In case you missed it, note that I posted a reply just above yours!
Would it be infinitely scrollable, though?
If you reset the cursor to the centre of the screen, or use “relative mode” (on those operating systems that support it), yes.
base.win.movePointer(0, x, y)
Where “x” and “y” are the desired points–in this case, the centre of the window, i.e. half the width and height of the window, respectively. The width and height can be had via calling “getXSize()” and “getYSize()” on base.win.
(I’m presuming that you’re just using the default window, hence “base.win”; adjust for your case if that’s not accurate!)
“Relative mode” is described in the “mouse support” page to which I linked above.
(I think that support for an OS-independent “relative mode” is in the works for a later version of the engine, but not available yet, if I recall correctly.)
In fact, I see that there’s a useful-looking example on that same “mouse support” page, under the heading “Confined mouse mode”.
Thank you very much! Would it run on windows 7/10, Ubuntu, and LXDE (Raspian) at least?
I forget which operating systems support relative mode, offhand–a search of the forum should turn it up.
However, personally, I just don’t use relative mode at all–I just use the “send the pointer to the centre of the screen” method regardless of OS, which should indeed work on both Windows and Linux.
(That said, once the “universal relative mode” feature is implemented that will likely become the recommended approach, I imagine!)
I guess the whackiest solution is the best solution in this case then. Thanks for the help!