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

Get help using Construct 3!

Post » Fri May 26, 2017 2:09 pm

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!
B
5
S
1
Posts: 5
Reputation: 335

Post » Sat May 27, 2017 4:25 am

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. ;)
B
38
S
11
G
2
Posts: 46
Reputation: 3,916

Post » Sat May 27, 2017 8:50 pm

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?
B
6
S
1
Posts: 20
Reputation: 817

Post » Sun May 28, 2017 12:32 am

draganviper wrote: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...
B
38
S
11
G
2
Posts: 46
Reputation: 3,916

Post » Mon May 29, 2017 12:16 am

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! :D

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.
B
5
S
1
Posts: 5
Reputation: 335


Return to How do I...?

Who is online

Users browsing this forum: No registered users and 0 guests