python mouse jumps on game start

its all fine, but i’d like to eliminate the way that the mouse jumps up and right when i press P and start the game…

as in, like a first person shooter where you start the game and your view jumps up and right, but apart from the initial jump it’s all fine

-Luke

It’s because when you start, the mouse is usually FAR away from the center point. The mouse script calculates this, and makes the movement jump before setting the mouse to the middle. Make a scene that has python that just sets the mouse to the center of the screen, then switch to your main scene and it should be fine. I could be wrong, haven’t tested it:)

while it is true that it may not be center it doesn’t explain why each timei start it moves the same direction the same ammount… i will try the scene thing.

-Luke

well you could put the whole mouse script in an if statement, like this:


#All of your imports should stay at the top, along with
#Getcontrollers and sensors etc

if hasattr(GameLogic,"mouseinit"):
     #put the rest of your mouse script here
else:
     Rasterizer.setMousePosition(middlex,middley)
     GameLogic.mouseinit = 1

THis should ensure that NO mousemovement is made when the game is initially run. Still, I’m not totally sure if this will work.