Forum rules - please read before posting.

Please clarify regarding the connection of prefabs, their instances and ConstantIDs in action lists

edited November 2016 in Technical Q&A
I have a game object that exists in multiple scenes as instances of a prefab. 
This game object is a parent game object with quite a few nested child objects, some of which carry a ConstantID, and some other a RememberVisibility Script, too. 
All Constant IDs are "retained in prefab", and the parent object has a ConstantID, too.

In all scenes with an instance of this prefab, the player can trigger an action list that will switch the visibility of exactly one of these child objects to "on". For this purpose (and programming convenience) I send the name of the distinctive child object as a parameter to the action list (*see additional remark below).

What I try to achieve is the following:
  • In scene A, the player triggers an action which will make (child) object #1 of the parent GameObject's instance visible. This child object of course has a "RememberVisibility" attached.
  • When Player enters scene B, C, D and so on which also contain an instance of the same entire parent GameObject, child object #1 is also visible.
What does happen though is this:
  • In scene A, the player triggers an action which will make (child) object #1 of the parent GameObject's instance visible. This child object of course has a "RememberVisibility" attached.
  • When Player enters scene B, C, D and so on which also contain an instance of the same entire parent GameObject, child object #1 is still invisible.
  • When Player returns to scene A, child object #1 however is remembered correctly as visible, as it should be. But only there and nowhere else.
So obviously the visibility information of child object #1 in scene A doesn't make it through to its prefab, and neither to the prefab's instances of scene B ff, although they all carry the same ConstantID. This may be intended behavior to keep the prefab save from alterations, but I do not know if this is the case – and if it was, what is the ConstantIDs' purpose in such a scenario then? 

(*) When assigning the child GameObject, which is supposed to become visible, to the parameter of the action list, I of course can choose whether to use the scene's instance of it (under the Scene tab) or the prefab (under the Asset tab):
  • When I choose the scene's instance, things happen as described above and child object #1's visiblilty information will at least be saved to the scene A, but not inherited by the instances of child object #1 in other scenes.
  • When I choose the prefab from the Asset Tab, nothing happens whatsoever and the visibility of child object #1 would not change at all (and does also not get recorded) – which I believe makes sense, as the instance in scene A is already instantiated when the action list gets triggered.
Again – all of this "not-working" seems plausible to me as regards saving prefabs from undesired overwrites, …

… but what is the right way then to "beam" visibility information of a prefab's child object instance in scene 1 to its clones in scene 2 to N? 

If I could, I would pass the child object's ConstantID to the parameter directly, but AC's UI does not seem to allow for this.

Or is this maybe a current limitation and should I better switch to setting objects' visibility status "OnStart" of a scene, dependent on some extra global variables?

Comments

  • edited November 2016
    While it may not be giving you the behaviour you wish for, the description does sound correct.  While the object in question may be a prefab, and be present in other scenes, AC still treats each per-scene instance as a separate entity.

    This is intentional, as all saved scene data is isolated from one another so as not to have one scene wrongly affecting another (for example, if two unrelated objects in two separate scenes somehow has the same CID number).  It's not a limitation, but it is a safeguard.

    The purpose of a CID number is to allow assets and scene-objects (typically, ActionList assets and scene objects they affect) from finding one another regardless of scene reloading etc.

    The correct method, as you suggest, would be to store the desired visibility state as a global boolean variable, and then use an ActionList Asset linked to your OnStart / OnLoad Cutscenes to set the visibility manually.  So as not to interfere with AC's save system, I would recommend removing the RememberVisibility component and rely just on your own global variable.  This same Actionlist asset can be used to amend any other such component that behaves like this.
  • All of this makes perfect sense, Chris — thank you so much (again) for taking your time to explain things.

    Best, Jensen
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.