How do I select or create an object by instance name.

0 favourites
  • 8 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • 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?


  • I'm not 100% I understand what you're getting at, but it sounds like the instance you're creating is spawned after dragging and dropping one of these colored objects, is that right?

    I'm assuming you would need to toggle the type of object you're wishing to create (I'm conceptualizing a tower defense style thing here). If that's the case, maybe you can have a variable that changes to the name of whatever object needs to be spawned when you select it. Then, when the colored object is released, it spawns the object with the name of that variable and is destroyed.

    Again, let me know if that's way off base.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I just wanted to pick an existing instances.

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


    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.

    It worked perfectly!

    Thx for the reply!

  • I don't suggest using UID's to pick unique instances, because if you destroy objects the UID changes. You can add an instance variable to your family and every time you create object from it increment it by 1, then pick the instances with that ID.

  • Solution:

    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.

    It worked perfectly!

    Sure, that somehow works. And next ?

    Are you going to write 4000 events to follow that up? Like ....

    1/ If this .... then pick UID this ... and do this ...

    2/ If that .... then pick UID that ... and do that ....

    3 to 4000/ If something else .. then pick UID something ... and do something else ....

    Should explain what exactly you wanna do.

    At this point i am afraid that you gonna create a vehicle that will overshoot the moon.

  • cedlal There is a plugin and a behaviour named "nickname". This enables you to give all your objects a nickname and then simply create any object by name.

    So if you have a family and want to create a specific object in the family you simply just use the action "create nickname".

    So it is a very very useful plugin that I highly recommend which saves you a lot of time and makes things a lot less complicated.

    Here it is for C2:

  • imhotep22 You are totally right! They explain how to do this in the documentation and it makes a lot of sense. I will pick the instance from the instance variable - ID instead of the UID provided by Construct.

    Anonnymitet It seems like a very useful plugin! Unfortunately I cannot use it, I'm already using C3 because I'm working on a mac and the plugin is not adapted to C3. I Hope it will in the future.

    99Instances2Go I'm picking a couple of objects randomly from the family and I add them to screen at random X position, the objects are created at runtime (no spawning).

    Thx to all of you!

  • That is not how 'creating' works. If i understand you right, i still see no tree.

    I have the impression that you try to pick/select an object and then try to create that object.

    Picking an object in a parent condition has totally no effect on which object is created in the paired action.

    Kinda logical, cant pick a non existing object.

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