Suspended scene still being updated?


So, I made a pause menu. When I press ‘ESC’, my pause menu is added as an overlay. Inside the pause menu scene, I suspend the main scene. But, I notice that if I pause and click ‘Resume’ to resume my main scene, the camera moves to adjust to where my mouse was in the pause menu. Blend here.

untitled.blend (763 KB)

It’s not updating… The mouse moves to it right where the mouse should be because that’s what’s supposed to happen. I tested it using an empty that emits objects every second.
I played the game, and waited until the object emitted 5 objects. I paused the game, went and made a sandwich, and played it. There were still 5 objects.

It works fine.

Well that bugs me that it moves the camera.

Well the mouse moved so the view moves too. The view jumps to the new mouse position when you unpause.

if you save the position of the mouse when you pause you can return the mouse to that position before unpausing the scene, then the mouse look won’t move.

Or, you could center the “resume” button.

Hmm. I like both those ideas.

I paused the game, went and made a sandwich

for some reason this makes me laugh

Set the mouse position to the middle of the screen right before you resume the scene.

My only problem @Linkxgl and TheKingDweeb, is what if the player was not looking straight forward?

Mouse position is relative to the player camera. I don’t think it should matter where the player is looking.

:spin: Maybe I’ll try Smoking_mirror’s idea.


Honestly, just set the mouse position to the middle of the screen right before unpausing.

It’ll work out like this:
Pause -> Suspend Scene -> Mouse is free (since mouselook is also suspended) -> Unpause -> Lock mouse to middle -> Resume Scene
This works for all situations, your mouse starts in the middle of the screen where it’s supposed to and the camera moves relative to that. I’ve done it before, it works perfectly.

Well how would I lock the mouse to the middle?

logic.mouse.position = (0.5,0.5)

Thank you.

EDIT: Hmm, it seems that it doesn’t work. I mean, it works, but the camera still moves when I unpause. I’m just using a left mouse click sensor.

Seems that variable is read only so you will have to use:

bge.render.setMousePosition(int(bge.render.getWindowWidth()*0.5), int(bge.render.getWindowHeight()*0.5))

Ive modified your .blend for you (129 KB)

Be aware, the camera moves AFTER you resumed the scene. This is because the mouse position changed since pausing.

When you use relative mode (setting the mouse to the center of the screen at each frame), it might be a solution, to center the mouse position before performing the camera rotation.

@Monster I’m not sure I follow. How would I do that?

I just looked at the blend and that’s an insanely complicated mouse move script. Where did you get it?

Some of the solutions people are suggesting might not work because of the script, it’s nearly 800 lines of code so I didn’t have time to go through and find out what’s wrong, who knows how it works? Or why in this case it doesn’t work.

Did you write the script yourself? If not I’d recommend trying an easier script that you can understand. It’s cool that it works with only an always sensor, but it’d be better to use a more functional script which you can customize yourself if you need to.

The fixed blend worked fine with me. ^^