Forum rules - please read before posting.

Scene Switch problem - Camera and Inventory messed up on switch

Hi all, I'm 0 for 2 this weekend, but this is potentially an interesting problem:

I have 2 scenes. When I go from A to B via Scene: Switch, in B the default inventory bar appears to black out and stick 'on', and the camera constraints (x/y axis) are ignored. Then, when I return to the first scene A, the assigned NavCam is completely ignored for the Main Camera instead (?).

  • Yes, both scenes are in Build Settings.
  • Yes, I assigned Previous Scenes and a Camera on Start for the Player Starts in both scenes.

  • No, I probably did not make the scrolling scene (A) correctly. Could this be the problem? My Main Camera's viewport rect is set to capture a long horizontal background image, while the Nav Cam is size 4 and follows the player sprite through the space. Video of the entire sequence here (change the quality settings to 1080 so it's not blurry...sorry).

  • I went ahead and tested the switch with a scene with a more regularly sized Main Camera (like in the 2D AC 90 min tutorial) but the problem remains when I get to the new scene, the inventory bar is blacked out and the nav cam constraints are ignored. Video of that here.

  • If I start in B, the camera constraints and inventory work as expected. If I switch to A with the 'regular Main Camera', A is fine, but when I go back to B, the camera and inventory are messed up again.

I'm using Unity 2018.3.7f1 and AC 1.68.4.

What am I doing wrong? I hope this makes sense and that the videos help clarify.
Thank you!!

Comments

  • Interesting indeed - I haven't seen such an issue before.

    It looks like only a portion of the screen is rendering. Where the inventory permanently shows, or the cursor graphic repeats, it looks like the camera isn't rendering to there so nothing is updated.

    First of all, is the "_GameCameras" folder object at the origin? The Console is warning about the MainCamera being parented to an unexpected object, but this can be ignored if _GameCameras is at (0,0,0) and never moved. Do you get any other Console messages?

    Let's see images of your MainCamera's Inspector in Scene A (at runtime) both before and after the issue occurs, as well as your full Settings Manager.

    If Force aspect ratio? is checked, try unchecking it.

    Try also switching to the 2D Demo scene, Park, both before and after the issue occurs. Do things revert to normal after either attempt?

  • Hmm, curiouser and curiouser.

    1. _GameCamers folders in both scenes are at the origin.
    2. Force aspect ratio remains unchecked.

    I experimented a bit as you suggested and documented the results here.

    The link also contains Inspector and Settings Manager screenshots.

  • Well, actually, I've no idea why, but everything is working now. I deleted and rebuilt the inside scene and didn't mess around with the camera rects this time. Still getting an unsaved NavCam warning though...?

    To achieve the continuous background, I changed the Main Camera to perspective with a Nav Cam that follows the player. It works even works when I switch scenes!

    Thanks for your help, Chris :)

  • The NavCam warnings are unrelated, but important to heed in order to implement the ability to save the game. You can generally just click "Auto-add Save components to GameObjects" at the top of the Settings Manager, but it's important to go through the Manual's "Saving scene objects" chapter to understand the principles.

    Yes, it's definitely down to the Camera's "Viewport Rects" field. This controls which portion of the screen gets rendered, so you should use either the Transform component, or the controls in the GameCamera2D's Inspector, to control what it displays.

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.