Issue with my mouselook setup

I have created a game with a pause menu that suspends the main scene, the main scene uses mouselook. Problem is that when the game un-pauses the mouse shutters to the last position it had on the pause menu. This is also the case when starting the game, it will start from where my mouse is.

What I need is a way to center the mouse upon beginning the game and also upon closing menus.

Any ideas?

I am uploading a video but it’s taking longer than expected to process.


from bge import render

def getWindowSize():
    return (render.getWindowWidth(), render.getWindowHeight())

def getCenter(size):
    return (size[0]//2, size[1]//2)

def centerMouse():
    size = getWindowSize()
    center = getCenter(size)
    x = center[0]
    y = center[1]
    render.setMousePosition(x,y)
      
centerMouse()

Amazing, this does EXACTLY what I wanted. Cheers.

That was taken mostly from @Riyuzakisan, so all credit goes there.

Thanks Nines! Thats exactly what I just needed:D