How do I select an object by instance name within a family.

0 favourites
  • 5 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • I have a family (colors) that contains 3 objects (blue, green, red). I want to select or create each one of them by name. (dynamically)

    I'm using a familie because they can be drag&drop and they behave the same way and the familie will contain much more objects.

    I thought I had 2 options to achieve this, to select them by instance name or to create them one after one.

    If I create one object from a familie it creates automatically all the objects from that familie. (not an option)

    I didn't found a way to select the object by instance name ?!?! (weird because it's usually a very basic to do but doesn't seem to be an option)

    How can I achieve this simple task?

    Thx!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi cedlal, can you be more specific about what you're trying to do? I'd like to help but I'm having trouble understanding your question. I can't tell if you're trying to only create new instances or pick existing instances. In other words, are you trying to spawn things or manipulate them after they are spawned? (Or both?)

    If you're just creating new objects, you can do that easily enough either through "System:Create object" (which uses a dialog to select the object to spawn) or "System:Create object (by name)" (which you can pass a string to that's the name of your object type). However that's not the same as picking/changing individual instances after they have been spawned. I ran into that problem earlier today, and I'm not sure if there's a direct way to pick instances just created by name. I suppose you could give each object type an "Initialized" boolean and every time you spawn an instance you spawn loop through ALL instances in the game to find the one that wasn't initialized, pick it, do some operation on it, and set the boolean to "true". But that's such a hack it makes me shudder.

  • Couldn't you just put the UUID of the instance into an array or something and then get a handle on it that way later?

  • Couldn't you just put the UUID of the instance into an array or something and then get a handle on it that way later?

    Yes, that's true, or you can capture the UID in a local variable right after you create your object, and once you're a level higher do some action on it - I think this works whether you create by name or through the standard create object method. Not sure what I was thinking when I wrote that last night tbh - I think I'm suffering game jam delirium.

    I still wish I understood what the OP's question was though...

  • Yes, that's exactly what I've done and it worked perfectly!

    I've sent the UID of all the objects from the family in a array and then I create an event "Pick instance with UID - UID number from the array" from the family.

    Thank you for your help!

    I wanted to pick an existing instances.

    In other language I could pick an instance from the instance name that's why I was confused.

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