Change scene and change camera

I have been struggling with the “change scene” and ended up with this method. Here’s a solved problem:

change active camera

When we change scenes, the camera from the previous scene is still attached. So the new scene will take over this camera, even if the new scene has a camera (awkward).


  • detach previous scene.activeCamera
  • change scene
  • attach currente scene.activeCamera

So, the position of the camera in each scene remains.

Here’s an example to change scene with double click.

If someone has a better way to change scenes and preserve the state, let me know.

The camera class takes a scene object as a constructor argument. You are manually changing what that arg does to keep it alive in the next scene.

There is really only one other choice & that is create a new one for the next scene. The choice kind of depends on everything else going on in your process.

You are also dependent on the position / rotation remaining the same, not to mention that you cannot change the camera class in different scenes. If that works for your scenes, fine.

1 Like