How do I get the uid of the just created object?

Get help using Construct 2

Post » Thu Mar 27, 2014 1:01 am

Hi,
how to get the uid of the last created object?
e.g.
I create an object (instance) on touch start. Then I want to address this instance (uid) to set variable values, or scale etc. But HOW?

pseudo-code:
Create Object at and return uid: obj_ball, touch.x, touch.y, var_obj // uid of created obj
with(var_obj) set variable value: new = 1

or:
create object at: obj_ball, touch.x, touch.y
with(last_created_obj) set variable value: new = 1

etc.
B
13
S
4
G
1
Posts: 107
Reputation: 1,337

Post » Thu Mar 27, 2014 1:08 am

you can set it to a variable...

newUID;

and right under Create Object do:
System set value of newUID to object.UID
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180

Post » Thu Mar 27, 2014 1:10 am

+ On touch
->create object myobject at touch.x, touch.y
->set global variable to myobject.uid

You can reference an object when it is picked.
An object can be picked in many ways.
One of those is when it is created.
Image ImageImage
B
169
S
50
G
169
Posts: 8,286
Reputation: 108,216

Post » Thu Mar 27, 2014 1:10 am

but really if you just set values under the Create Object action, all references will be to that specific object.. it's only if later you want to reference it that you would need to save the UID.
B
97
S
32
G
15
Posts: 1,199
Reputation: 16,180

Post » Thu Mar 27, 2014 9:46 am

Thanks
B
13
S
4
G
1
Posts: 107
Reputation: 1,337


Return to How do I....?

Who is online

Users browsing this forum: Solomon and 10 guests