Preserve UID when using "recreate initial instances"?

0 favourites
  • 4 posts
From the Asset Store
Create a boss fight with this easy to follow game pack. Recreate the classic attacks of Mutoid Man from Super Smash TV
  • Ashley

    The "recreate initial instances" action was created years ago as a result of numerous discussions here on the forums about how to best handle open-world metroidvania style games without every single room being in its own layout.

    I've used it extensively for both open-world and linear games alike, and it's one of my all-time favorite features Construct has to offer (I know right?)

    However, one major drawback with using it is that pre-placed objects (as in, objects placed in the layout editor that are expected to have a static UID) which are destroyed and recreated do not preserve their original UID, making it impossible to reference them for the purpose of linking/pairing objects, save data, loading object states, etc.

    I've resorted to making my own ID system using "for each (ordered)" which has its own drawbacks (I only get IDs at runtime) and then using manually set IDs / tags using private variables when this won't suffice.

    All that said, would it be possible to somehow reserve UIDs so that pre-placed objects which are destroyed and recreated using "recreate intial instances" get the UID they started with?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I don't know, it seems tricky, as it stands the engine could assign UIDs to other objects so they're already in use when you try to recreate other objects again. Are you sure there isn't a better way to solve this?

  • UIDs are pretty much the only way to reference instances outside of manually giving them IDs, so I'm not really sure what else I can do.

    Aren't instance UIDs stored in the layout XML? Is it not possible to just put them on a "do not use" list and then recreate them with those same UIDs in the same fashion as when the layout first loads?

  • You could also use "recreate initial instances" while all the previous instances still exist, so it can't give them the same UIDs. So even with some kind of reservation system the engine still cannot guarantee that the objects will get the same UIDs.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)