Forum rules - please read before posting.

Make "useless" GameObjects invisible or better remove them altogether?

edited June 2020 in Engine development


I have created a sort of PuzzleMachine in AC.
It is one complex parent GameObject with very many children, that again have children and grandchildren and so on, plus Component Variables attached for storing puzzle logic and progress. All in all, it is about 2.500 GameObjects "large".

This PuzzleMachine allows for setting up variations of different puzzle types and sizes just via a handful of parameters.
This setup (or initialization) of a puzzle occurs in the instant when a scene including this PuzzleMachine gets started for the very first time. And it occurs only once, runs completely to its end and autosaves its completed setup, even before the scene's GameCamera goes "on air".
So when the player returns to this scene later (or via a load), this initialization will not and never get repeated.

Now: before its setup, the PuzzleMachine consists of far more GameObjects (meshes and hotspots) than it actually needs after this setup procedure is done. App. 60% to 70% of the PuzzleMachine's children GameObjects are no longer useful once the setup is finished, and right now I have these obsolete GameObjects hidden via "Object: Visibility".

Now I wonder: is this the right way to handle things? Or is it better in terms of performance to get rid of them altogether by using "Object: Remove"? Does it actually noticeably matter?

My concern is that it might cause trouble to remove GameObjects that are being referenced in running ActionLists (even though, because of conditional logic, the Actions affecting those GameObjects never get called then).

Edit: sorry, wrong category! This was supposed to appear in "Technical Q&A".


  • AFAIK, it is indeed more performant to destroy a GameObject that disable it - and certainly moreso than just hide it's mesh. Though, the exact amounts would be a question for Unity.

    Rather than using AC Actions, though, it'd probably be better to attach a "self-destruct" script to any object you want to destroy. If children of it are still necessary, you'd have to re-parent those children to the object's own parent beforehand, but that could all be part of the same function.

    So far as AC goes, Action object references are re-connected are made at the time an ActionList is run. So long as an Action has recorded an object's Constant ID value, it doesn't matter where that object is in the scene - it'll find it again when the ActionList begins, provided a matching Constant ID is still attached.

  • edited June 2020

    I see - thank you, Chris.

    Removing the unneeded objects via AC Actions is indeed not an option, as I had to find out, because the ActionList-in-charge never finishes its task …

    What do you mean by "disable it", though? Is there a third option to deal with GameObjects in AC besides making them invisible or removing them? Are you refering to "Object: Send Message - Turn Off"?

  • I'm talking about disabling the GameObject itself. There isn't an AC Action for this, as it would cause the object reference to be lost, but you can do it through script with e.g.:

    myGameObject.SetActive (false);

    "Object: Send message - Turn Off" is a special command to handle most AC logic types, but it's not a generic one for any object. If sent to e.g. an AC Hotspot, it'll turn off the Hotspot - but won't affect the state of the GameObject it's attached to.

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.