object association

For questions about using Classic.

Post » Wed Jul 22, 2009 10:08 pm

hi! i've discovered construct some months ago and been using it and loving it since then. up until know i had no doubts but now that i'm starting a serious project i came into a problem : ex.: there's a bullet and its trace made of particles.. when a bullet hits [solid] it is destructed ... ok but how do i destroy its trace at the same time? is there some way to associate both of them at creation? (i know there's the containers but....) dont know if i made myself clear enough but thats my problem :?
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Wed Jul 22, 2009 10:32 pm

If there's only one of each object, then containers are the way to go. Otherwise, you can store the UID of one of the objects in another's private variable, and when destroying it, also destroy the other object with that UID in its private variable.
Scirra Founder
B
359
S
214
G
72
Posts: 22,949
Reputation: 178,544

Post » Wed Jul 22, 2009 10:40 pm

yeah it' the second case.. i will try storing and comparing the UID's then.... thnx ! :D
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Wed Jul 22, 2009 10:50 pm

oops.. how do i get the object's UID ?
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Wed Jul 22, 2009 11:47 pm

Using a container will run into another problem when doing a trace, or trail. You probably wont notice on smaller trace's but if its longer the trail will disappear faster than it should, because the particle is destroyed.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Thu Jul 23, 2009 12:07 am

If you want the trail particles to live longer than its "master", you could set a private variable in each of them with the UID of the "master", then when a "master" object dies you would look up their children comparing their private variable with the UID of the dying "master" object and set off a timer behavior to kill it later.

Doing so would kill the whole trail at the same time but a little while after the "master" dies.
Of course, you could also have the timer event set off timers for other children, in which case you can arrange some pretty complex dying orders just storing the proper UID in the proper particle.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Thu Jul 23, 2009 12:14 am

thank you guys i made it by associating and comparing UID's ! it works :D
B
58
S
13
G
10
Posts: 632
Reputation: 12,505

Post » Thu Jul 23, 2009 12:19 am

[quote="Madster":2usmaaf4]If you want the trail particles to live longer than its "master", you could set a private variable in each of them with the UID of the "master", then when a "master" object dies you would look up their children comparing their private variable with the UID of the dying "master" object and set off a timer behavior to kill it later.

Doing so would kill the whole trail at the same time but a little while after the "master" dies.
Of course, you could also have the timer event set off timers for other children, in which case you can arrange some pretty complex dying orders just storing the proper UID in the proper particle.[/quote:2usmaaf4]


interesting , it is more realistic that way ... the way i did the particles dont disappear right away... i'll do that thnx
B
58
S
13
G
10
Posts: 632
Reputation: 12,505


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 11 guests