Get a UID of an object through "Add Action"

0 favourites
  • 4 posts
From the Asset Store
This is a single chapter from the "Construct Starter Kit Collection". It is the Student Workbook for its Workshop.
  • Hi, how do you get a UID of an object through an action in construct 2?? Thanks

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi danispag

    You can set a variable in an action to a UID:

    On event: Set yourVariable to Object.UID

    You can add a condition to the event to pick a specific instance of the object e.g.:

    On event|Object.instanceVariable = 0: Set yourVariable to Object.UID

  • I often like adding an OID (Owner ID) instance variable to objects created by another object, so they're always a part of each other. I suggest doing that if you use objects like archetypes. For instance, in Byte Sized Heroes, I have two Objects for every character, two for every bullet, two for every vehicle, etc. I have a MASK, and SPRITE, which both have OID variables for everything. So, if, for instance, I want to know where a bullet came from, I just select the object with a UID equal to the OID of the bullet.

    Also, I tend not to call it PID (Parent) and CID (Child), because PID can easily be confused with PeerID, which is used in multiplayer.

    Just some tips.

  • THank you so much

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