Making 1 object follow rotation of other object in another scene.

What I need to happen is to make a camera in a 2nd scene constantly track the rotation of a camera in the 1st scene. I’ve tried parenting, but that doesn’t work on objects in different scenes. :spin:

I have 2 scenes, 1 is the world and the other is the sky. Both have a camera and the primary scene is the world one, which has the main camera that underlay’s the sky scene via logic bricks. But i don’t have a game mechanic that would make the sky scene camera follow the same orientation as the world camera every frame, and i don’t have any skills required to make a python script. If anyone cold figure out a few lines of Py that would do this i would be grateful. Also some other subs that might answer this question, comment them.

And note that I need an in game script, not an API.

As this was discussed in the past I suggest to search for “skybox”.

Anyway you describe the usual way. You constantly copy the orientation from one object to the other. That is pretty simple. But … it will create a one frame delay. This might sound as it is not much, but it is noticeable especially as the whole screen is involved.

Therefore I suggest to have three cameras.

  • One master camera that performs the motion.
  • One slave camera in the master’s scene that copies the master’s orientation and position.
  • One slave camera in each subsequent scene that copies the master’s orientation.

You see through the slave cameras rather than the master camera. The consequence is … you get two cameras in one scene.

The code is simple:

import bge

def copyOrientationToActiveCameras(controller):
    master = controller.owner
    for scene in bge.logic.getSceneList():
        scene.active_camera.worldOrientation = master.worldOrientation
        if scene is master.scene:
            scene.active_camera.worldPosition = master.worldPosition

Always [TRUE level triggering] -> Python Module: camera.copyOrientationToActiveCameras

The position will be copied when the slave is in the same scene as the master otherwise the view would never move away ;).

Attention: do not parent the slave to the master. Otherwise you get the one frame delay back.
I hope it helps

Hint: for easier editing make the master camera the default camera and dynamically switch to the slave camera at game start:
Always -> AND/OR -> Scene Mode “Set camera”

What has to run the script?