Changing camera {position) on pause - best practice

When the player pauses a game I’d like to change the camera position (to give a panorama of the play area) and disable game play. I can think of a couple of possible ways to do this:

  1. on pause move the camera, and detach any controls, then restore on continue,
  2. share assets between playable and paused scenes and switch between the two.

My inclination is towards no 2. Am I right? Or is there another, better way (or best practice)? Or is it a suck-it-and-see free-for-all?


In your logic I would probably have a kind of attach detach functions to ensure controls and timer do not impact the game while in pause.

I would also have 2 cameras, the game one and the pause one and simply switch between both when the pause state changes.

1 Like

OK, but wouldn’t using scenes give a higher cohesion and looser coupling? The functionality would be bound to a single entities allowing them to be switched with a line or two rather than setting and storing a growing list of properties and behaviours?

If the content is different yes it is obviously the best choice but as in your case you want to share the content and only change the camera position and prevent players to interact, it sounds easier in one scene. It should not be a huge list, as it is mostly only player interactions ???

Short answer, I don’t know. I’m aware that I may be over-designing this, which is why I’m asking about best practice.

I’m working around Babylon’s render loop which feels “alien” to me. Normally I’d have state models which would hold inputs, model, etc. then just change state. Babylon doesn’t fit that model.

I’ll probably try both ways.

Are there any other ways of achieving a pause “state”?

Ah. It looks like scenes can’t enabled/disabled so observables will always be active. So that knocks that idea on the head.So property changes it must be.

Which observables of scene are you speaking of ?

The inputs one can be stopped by calling detach or attach. For the rest as long as you do not call scene.render, nothing should happen.

Aside of this I am not sure what issue the render loop is causing. I am usually not even thinking about it, I kind of condider it only as a request animation frame helper.

I also rely on state heavily and I never had such kind of issues.

You would actually have the same issue in other engines I guess as you would need a global pause/run state and query it to know what to do as you still want rendering but from a different camera without your normal game animations or maybe even different ones.

You could actually do the exact same here ??? (I might completely miss the point so do not hesitate to let me know :slight_smile: )

Couldn’t you change it’s position then just do a camera.update() ?

to start with

Elsewhere I encapsulate all the required functionality including input handling in separate state objects and switch between them as required.

Babylon ties input to cameras and the scene, so I can’t do that. I’ll probably have an intermediate delegate object which holds some of the state functionality, with some input being tired to the scene it’ll be a weird mutant hybrid.

Do you have any examples of how you handle states?