Get a UID of an object through "Add Action"

Just started using Construct 2? Post your questions here

Post » Wed May 17, 2017 10:30 am

Hi, how do you get a UID of an object through an action in construct 2?? Thanks
B
4
Posts: 4
Reputation: 208

Post » Thu May 18, 2017 8:06 am

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
B
16
S
7
G
3
Posts: 396
Reputation: 3,700

Post » Fri May 19, 2017 12:54 am

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.
ImageImage
B
44
S
13
G
2
Posts: 252
Reputation: 6,246

Post » Mon May 22, 2017 3:38 pm

THank you so much :)
B
4
Posts: 4
Reputation: 208


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 1 guest