I want to create demo/tutorial for a game. For this purpose i need to emulate user’s mouse inputs. I found a class that apparently does this feature: VirtualMouse from panda3d.core.
This class is not well documented neither mentioned in the manual. So I just created an instance:
self.vmouse = VirtualMouse("vmouse")
And modified position of the mouse:
However this does not work and the mouse isn’t moving
Any suggestion/help on how to use VirtualMouse class?
Ps: For now I am using an alternative:
base.win.movePointer(1, self.x, self.y)
But really wanted to understand how VirtualMouse works
Was it you who asked a similar question on the IRC channel recently? Well, I don’t know how games out there do that tutorial stuff. But I am pretty sure the method is not to emulate mouseclicks. Wouldn’t make sense. The mouse movement coming from a human player is just too much to keep track of. Just like a demo of a strategy game does keep track of the results of mouse clicks, but not of the mouse itself.
I am pretty sure to show a user how to do things, you 1) freeze user input, 2) lerp pos the mouse from current pos to target position, 3) indicate a mouse click through audio (click sound) or video (animation), 4) call the function a mouse click would call.
No it wasn’t me who asked the question on ICQ
Anyway thanks very much for the answer and suggestion to make an animated game tutorial.
Note that the mouse pointer onscreen should not normally be controlled by the application (and the only way to control it is via the movePointer() call you have already found, which isn’t supported on all operating systems because it’s considered poor design to move it). The mouse pointer is the user’s to control, he doesn’t expect the application to move it for him.
The VirtualMouse object is designed to substitute for the mouse control; you can use it in place of the MouseAndKeyboard object, to feed it input from some other source (for instance, a joystick, or a motion tracker). It could also be used to simulate user input for a tutorial, I guess, though this would be a strange usage; and moving it wouldn’t actually move the visible mouse cursor.
But to answer your original question, you have to parent the VirtualMouse node into the data graph in place of the MouseAndKeyboard node that ShowBase puts there.
Thanks a lot David for the answer !