Forum rules - please read before posting.

PersistentEngine and asset references

Unity 2019.4.4f1 - AC v1.72.4

Hey, I'm in the process of preparing my game for release on PC and porting to consoles (which is primarily handled by someone else).

I've been running through the Performance and Optimisation section of the manual to make sure I've done everything possible to increase performance and load times before handing over to porting.

1: Firstly, I'm having trouble finding the 'Spawn PersistentEngine prefab from Resources?' option in the AC Game Editor - Settings window. I keep checking and can't seem to find it, doesn't seem to be an option listed in the SettingsManager asset itself either.

Secondly It would be great if you could clear up some confusion I have regarding resources subfolders/addressables for asset references. I have successfully setup asset bundles for all of my speech files, which are working and have improved load times significantly. I'm now at the 'Use Addressables for asset references' part of the optimisation chapter.

I don't have any files in my project's resources folder, the only thing I had in there previously was my speech files. I do however use things like Object: Change Material, Object: Add or Remove and Sound: Change Footsteps frequently throughout the game.

2: Do I need to go through the whole game with a fine tooth comb and take note of every time an action like this is used so I know which files to make addressable?

3: Is there a more automated approach for this? (similar to the auto-add remember components).

4: How do I know exactly which type of assets need to be made addressable? I noticed if using resources folders, the names for saveable data folders are listed. Would these be the sort of assets I need to make addressable?

I'm a little confused because save files/data seem to be working fine at the moment and retaining things where Object: Change Material is used, despite me not having any saveable data folders setup.

Hopefully there is a fairly straightforward solution for this, I fear this is all getting a bit too far out of my comfort zone!

Comments

  • edited April 2021

    I'm having trouble finding the 'Spawn PersistentEngine prefab from Resources?' option in the AC Game Editor - Settings window

    This was made available in the v1.73.0 update - you'll need to import the latest release to make use of it. Be aware that Unity's Package Manager has had some issues regarding making the wrong version available for assets. Try importing via the Asset Store window if it's not giving you the latest version.

    Do I need to go through the whole game with a fine tooth comb and take note of every time an action like this is used so I know which files to make addressable?

    The ability to use Addressables for asset references is also a v1.73.0 feature, but it's not always necessary to save such references.

    Changing an asset reference through Actions doesn't itself necessitate setting up a reference to it. That's determined by what Remember components you make use of.

    For example, you can change a material with the Object: Change material Action, but it's the Remember Material component that saves which material should be applied to the object. Depending on how you've set up your game - e.g. by manually assigning the object's default material in your OnStart cutscene - you may not always need to save this asset reference using a Remember component.

    The Actions you use to make such changes, however, can be found via the Actions Manager. If you navigate to a specific Action type, the cog menu beside it will let you search the project for all instances of it.

    Is there a more automated approach for this? (similar to the auto-add remember components).

    Unfortunately not. Particularly true of Addressables, it's not so easy to determine if an asset of the correct type exists in the correct location.

    How do I know exactly which type of assets need to be made addressable? I noticed if using resources folders, the names for saveable data folders are listed. Would these be the sort of assets I need to make addressable?

    Addressables and SaveableData folders are two solutions to the same problem. If you're currently using such folders and want to switch to Addressables, then the assets in those folders will be what you want to convert - and then move out of the Resources folder completely.

    I'm a little confused because save files/data seem to be working fine at the moment and retaining things where Object: Change Material is used, despite me not having any saveable data folders setup.

    SaveableData folders are optional - the important thing is that such assets are either placed in a Resources folder, or made into Addressables. Having SaveableData subfolders in your Resources folder is a way of making them easier (and faster) for AC to find, but the fastest method is to rely on Addressables.

    Hopefully there is a fairly straightforward solution for this, I fear this is all getting a bit too far out of my comfort zone!

    It may be worth trying the concepts out in a fresh project with minimal other assets - it certainly can be a tricky topic!

  • edited April 2021

    Hi Chris, thanks for the lengthy reply and apologies for the delayed response.

    I've spent some time refactoring my project a little and getting familiar with the manual when it comes to saving.

    It's probably easiest for me to lay out my understanding of the subject and what I've setup, then please let me know if I'm doing things wrong anywhere.

    Firstly, I'm not using addressable for anything other than speech files. For the purpose of getting this functional I'm just using the resources folder.

    I have lots of objects in many scenes that are added or removed at various points in gameplay using the Object - Add or Remove action. I want these objects to have their state (either present in scene hierarchy, or removed from the scene) saved when the player saves.

    Each object has a remember transform component on it (auto added by AC).

    I've gone through and made sure that each one of these objects is a prefab in the Assets/myProjectName/Resources folder, I've done this by simply dragging each of the objects from the scene hierarchy into the resources folder, which creates a prefab with the same constant ID number as the object in the hierarchy.

    My issue:

    I'm finding now that consistently, after playing the game past an Object - Add or Remove action, when loading a save game made previous to that, the object is no longer in the scene.

    If I enter the game anew via play mode the object will be there as it should be (good), if I then load a save made after the Object - Add or Remove action has been run it's no longer there (good), however if I then load a save made before the action (without restarting the game) the object isn't there (bad).

    Any I missing the point somewhere? It seems that whenever an object is removed it stays removed until the game is restarted, regardless of loading saves.

    Any help would be really appreciated, this is the last 'bug' left to tackle before I can handover for porting.

    If it helps, here's the two inspectors. The scene object on the left and prefab on the right:

    https://i.imgur.com/3OvKUid.png

  • edited April 2021

    Okay, so it seems Object - add or remove is probably the worst choice I could have made in some of these cases. I wasn't aware at the time that I would need to make them all prefabs to get save/load functionality working.

    A lot of these objects are hotspots (as you can see) and making them a prefab loses their connection to the scene actionlists for USE etc.

    I appreciate this is a bit of a mess, would you recommend something like moving the objects really far away from the play area? I can't simply disable these hotspots because I use a custom script that enables them under certain circumstances (hence using object - remove).

  • I think I've resolved this now, went through and replaced any instances of object - remove for stuff like hotspots and characters with an object - teleport to Y -10000. Also added any appropriate object-visible false etc alongside them.

    I was tripping up by checking if the hotspots had loaded correctly by simple trying to trigger them, rather than checking the scene hierarchy for them. Seems they were loading but with broken connections to their USE actionlists.

    Phew. Rookie mistake that caused a lot of headaches.

  • Spawning/removing objects at runtime can be a bit tricky, but can be a valid option at times.

    The Remember Transform component looks fine - though you'd have to check Retain in prefab? on the Remember Hotspot to ensure its ID is consistent.

    Otherwise, so long as the prefabs name was unique - and it was either placed in a SaveableData/Prefabs folder or not at all - it looks like that should be spawning in.

    Though, it's true that you'd have trouble with ActionLists in prefabs. The way around this is to set your Hotspot's Actions source field to Asset File, and rely on ActionList assets for your interaction logic.

    Teleporting your objects off-screen is also a valid solution as well, though.

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.