Forum rules - please read before posting.

Previous Scene Remembers Camera

Hi, 

I'm using multiple cameras in one scene and I'm switching between the cameras as the game progress. I'm also using a custom action to switch to the previous scene with this, AC.KickStarter.sceneChanger.ChangeScene(AC.KickStarter.sceneChanger.previousSceneInfo, true);

Here's the problem, I would like to be able to switch back to a scene with the last used camera. However, every time I go back to the previous scene, the camera is not remembered even though I added a constant ID to all the cameras. Any ideas?

Comments

  • The "last used" camera is not accounted for when switching scenes naturally (i.e. through gameplay as opposed to loading a save file).  Instead, the GameCamera associated with the appropriate PlayerStart is relied upon.

    How many cameras are you talking about?  You could store the "exiting" camera's Constant ID number in a Local Integer Variable and retrieve it again once the scene is entered again.  It might be a bit cumbersome if you do it with AC's Actions, but if you're fine with custom Actions / scripting it should be quite simple:

    To store the current camera ID in Local Variable 3:
    int currentCameraID = AC.KickStarter.mainCamera.attachedCamera.GetComponent <ConstantID>().constantID;
    AC.LocalVariables.SetIntegerValue (3, currentCameraID);


    To then retrieve it and switch camera afterwards:
    int currentCameraID = AC.LocalVariables.GetIntegerValue (3);
    AC.GameCamera lastGameCamera = AC.Serializer.returnComponent <GameCamera> (currentCameraID);
    AC.KickStarter.mainCamera.SetGameCamera (lastGameCamera);

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.