Does Construct have a ID for each instance?

This forum is currently in read-only mode.
From the Asset Store
Casino? money? who knows? but the target is the same!
  • I'm sry if i have a stupid question. I'm new and my english is poor...

    Can i get the ID of instance when i create it and use this ID to set variable and action? I want to control each instance but i don't know how to do. When i try something with an instance, it do for all instances with same object. And when i want to select some instance with same object (same as RTS selecting unit) i have got a big problem. :< How can i do that? Please help me.

    Thank for reading.

  • Yes each instance will have an id, the uid, but that wont help with picking.

    The usual method for picking is to give the object a private variable, and when you create an instance give that instance a different value in its variable.

    You can then compare that variable, and any instance with that value in its private variable will be picked.

    mouse&keyboard on left clicked

    -system create object sprite at 100 x, 100 y

    -sprite set variable to 1

    sprite compare private variable = to 1

    -sprite set x to 200

  • Can't i use (instance_id).variable=x to set private variable of instance? *sob* That's too hard to make a game with so many instance if i must test all... Can you give me a demo? Thank so much for your help.

    Bad... my mom is flamming, i must go to bed now.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • If you give us an example of what you are trying to do we might be able to suggest something a little more specifically.

  • I don't know how to make a example with Construct and my english again is so bad. Can i use GML (Language of Game Maker)? It is a simple way i can to tell what i'm trying...

    for(i=0;i<=350;i+=10) 
        {
        //create the instance and get ID of it.
        id_of_instance=instance_create(x,y,obj_bullet);
        //use ID of instance to set variable.
        (id_of_instance).direction=i; (id_of_instance).speed=5; 
        //or use ID of instance for event control. 
        //This make a same effect with the above.
        //with (id_of_instance) motion_set(i,5); 
        }
    [/code:38cyzzz5]
    
    and this is product:
    <img src="http://www.freeimagehosting.net/uploads/17c8f7d2c8.png">
    gmk file: [url=http://www.box.net/shared/5f0xz7vmxk]http://www.box.net/shared/5f0xz7vmxk[/url]
    exe file: [url=http://www.box.net/shared/16ydbytiyp]http://www.box.net/shared/16ydbytiyp[/url]
    
    I want to do same things with Construct, how can i? I'm going to make a bullet hell game. It have so many instance of bullet in a screen and complex movoments. Where is best way for it?
    
    Thank so much for reading and help me.
  • The UID of an object is based on all the existing objects, including text, behaviors etc.

    So it wont help here, as it would be pretty hard to keep up with all of the possibilities.

    However there's no reason you can't give each instance a value of your own choice.

    http://dl.dropbox.com/u/666516/varpick.cap

    Note:

    In this example I used a global variable as a placeholder for advancing the value of the variable.

    Setting, or adding to a private variable is a bit tricky as each instance is given the default value on creation.

  • The UID of an object is based on all the existing objects, including text, behaviors etc.

    So it wont help here, as it would be pretty hard to keep up with all of the possibilities.

    However there's no reason you can't give each instance a value of your own choice.

    http://dl.dropbox.com/u/666516/varpick.cap

    Note:

    In this example I used a global variable as a placeholder for advancing the value of the variable.

    Setting, or adding to a private variable is a bit tricky as each instance is given the default value on creation.

    Thank you so much. Something i can't understand but it's really very great example for me! I can study more things than what i wanted! Thank you so much again!

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