Forum rules - please read before posting.

Couple of scene loading issues

Just a couple of things I've come across when loading a save that I can't quite figure out:

  • The 'Whenever an Inventory item is added' event is triggered for the last item that was added whenever I load a save. (This includes items that are marked as 'Carry on start'

  • I have a scene with a single sorting map that sets the player's speed (movement is only on a left-right plane) and another scene (a close-up of an area in the scene). When I save a game in the closeup scene, then load it and return to the original scene, which has a start position on the sorting map, it seems the sorting map speed information isn't applied, result being the character walks very slowly. Reloading a save that's within the main scene applies the speed correctly.

Not sure if bugs or my own issues, but would appreciate knowing if anyone's come across this before or I'm missing something with the save system

Comments

  • Actually, just checked in the AC status window when loading, it appears to trigger the inventory item add event for all items in the player's inventory

  • Regarding the inventory issue: this is with the new Events Editor? Sounds like a teething issue: the event should fire when items are added during gameplay, but not when loading save files. I'll look into it, thanks.

    Regarding the sorting map issue: do both maps have a Constant ID component assigned? I'm not sure I'm understanding your set up correctly. If adding the components doesn't solve it, I'd appreciate a step-by-step breakdown on how to reproduce the issue.

  • edited August 2023

    Re: inventory, yes it's via the events editor, sounds good.

    I've added a constant ID to the sorting map, it doesn't make a difference. Let me try to describe the exact setup. Two scenes:

    In scene 1, the character is visible and player-controlled. There is a nav-mesh coving the bottom of the screen, covered by a sorting map.

    image
    image

    https://ibb.co/SdLShNs
    https://ibb.co/SwSpVmW

    The second scene has no sorting map, it's a close up of an object. The player is moved outside the screen bounds, and movement type sent to none (in custom code)

    When switching between the scenes in normal gameplay, all is fine. The player has a start position within the sorting map when returning from the second screen with movement scaling applied as expected. When loading a save in the second scene, however and returning to the first, the movement scaling isn't being applied.

    Thank you for looking into this, understandably this could be something I'm doing wrong or missing.

    (Sorry I have no idea what flavor of markdown the forum software wants to show these images correctly. It would be very helpful to be able to paste directly rather than having to upload examples to an image service, but understand if this isn't possible)

  • this could be something I'm doing wrong or missing.

    The steps involved sound fine - though it is possible to attach a Player component to an empty GameObject in the second scene, to temporarily override the default.

    I've attempted a recreation, but so far I'm not able to get the issue to occur. If you temporarily disable any custom scripts involved, does it then work?

    To be clear: the character appears in the correct place, at the correct scale, only with the wrong speed applied?

    Let's take a look at the save file itself. If you open up the Save-File Manager from the top of the Settings Manager, select the save-file and click the Data label to expand it.

    If you can share screenshots of the following, it may help reveal what's going on:

    • Top of the "Main data" section
    • "Sprites" section of the "Player data" section
    • The "Scene data" section for the first scene (the one with the Sorting Map)

    If in doubt, screenshot all and I'll sift through it.

  • edited August 2023

    Okay, so in the save data for the scene without a default sorting map, the bool on the player's sprite 'Follow default Sorting Map' is set to true.

    On load, again in a scene without a default sorting map, SetSortingMap on the FollowSortingMap Component on the player is called at line 1090 of FollowSortingMap.cs:

    else
    {
        followSortingMap.SetSortingMap (KickStarter.sceneSettings.sortingMap);
    }
    

    which turns off the followSortingMap flag, since there's no sorting map defined on the scene being loaded (presumably, with _sortingMap confirmed null in the debugger) FollowSortingMap.cs, line 240:

    public void SetSortingMap (SortingMap _sortingMap)
    {
        if (_sortingMap == null)
        {
            followSortingMap = false;
            customSortingMap = null;
        }
    

    The flag is turned off and after switching scenes and loading a new scene that DOES have a default SortingMap, the character is ignoring the sorting map entirely (both scale and speed, I was a bit unclear about that earlier). If I comment out the lines that sets followSortingMap to false, the new sorting map is respected and things work as intented.

    The SetSortingMap function is not re-triggered for the Player Object when loading a scene that does contain a sorting map, so the flag stays false and no sorting map is applied, even on later scenes that contain a sorting map. Confusingly (for me at least) SetSortingMap is never called at all when starting and playing the game without involving the load system, so that flag seems to be being left alone until a game is loaded.

    It doesn't seem intentional that that flag should be permanently set to false just because the particular scene the player is in when loading doesn't have a sorting map. I've turned off custom code and I don't think I have anything that would prevent SetSortingMap from being called, but as I say the sorting map does work until a save is loaded, despite SetSortingMap never being called explicitly.

  • Okay, so I can see the actual sorting map used is updated via 'UpdateSortingMap', which is indeed called on scene load, but that doesn't reset the 'followSortingMap' flag to true. Where should SetSortingMap usually be called from on a scene load?

  • edited August 2023

    Alternatively, changing line 145 in SceneSettings.cs from:

    followSortingMap.UpdateSortingMap ();
    

    to

    followSortingMap.SetSortingMap(sortingMap);
    

    Fixes the issue as well (which seems a bit more robust), unless we should intentionally be able to flag that the PC should always ignore sorting maps.

  • edited August 2023

    I see the 'Follow default Sorting Map' now in the 'Follow SortingMap' component in the sprite child, this is definitely selected and has been all along.

  • Thank you for the details, I will look into this.

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.