Get IID from UID?

0 favourites
  • 6 posts
  • Is this possible?

    var = Enemy(Enemy.UID.GETIID()).X

    How can i capture the IID using a UID?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Use a function.

    var ="getiid", enemy.uid)

    on function "getiid"

    pick enemy by uid function.param(0)

    --- function: set return value to enemy.iid

  • It works, thanks

    Now i have a different problem, all my family members (Enemy) contain the same IID

    I will search about it

  • The function won't work, as picking a single object will always return an index of zero. Maybe expand on what you are really doing.

    The UID is unique, the IID is just an index for the picked objects.

  • blackhornet

    The iid isn't related to picking, it's the instance number of the object type. I've utilized this to access values in unpicked objects. Off the top of my head, one use could be to compare two random instances of the same type.

    global number other=0

    pick random sprite instance

    --- set other to sprite.iid

    pick random sprite instance

    sprite x < sprite(other).x

    --- destroy sprite


    I didn't look into it previously but after a quick test iids are an instance number of a object type, not a family. So the object.iid will give the instance number of that type and not instance number in that family. However, the family(3).x style expression will give you the forth (counting from 0) instance in the family.

    A brute force solution could be to change the function to:

    on function "getiid"

    for each family

    system: compare function.param(0)=family.uid

    --- function: set return value to loopindex

    --- stop loop

    Another way could be to give the family an instance variable that you set to their index number when you create it. You'll also need to update it when an instance is destroyed. There's probably other ways too.

  • What would one do with the knowledge of the IDD (the index of a certain object in the list of picked objects) when all objects are picked ?

    Certainly when calling a funtion. I suppose the function gets called from a situation where there is certain picked object list. And one wants the IID of that object in that specific list. There is not one correlation between the picked list (and its indexes) in the event with the function call and the picked list in the on function (all and theire indexes when picked all).

    Just pick the instances (or objects with a famely) you want to pick. (make a picklist)

    Run trought them with a for loop

    Pick the instance by its IID (pick nth) = loopcounter

    This instance has an UID, but that is not importand now at this moment yet

    Set an instance variable to the IDD or to the loopindex

    Now you can pick any instance with an UID, its IID is in the instance variable.

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