How do I destroy oldest object

Get help using Construct 2

Post » Thu Jul 31, 2014 11:05 pm

I have turret firing projectiles and I want to destroy oldest projectile if X amount on screen.
I started with an array but couldn't get it to destroy anything. So I searched the forum for help and found this example, but still cant get it to destroy my projectiles. The array seams to work in the debugger If I remove pick instance with UID array.at(number).

Anyone have some idea how to solve this?

Haven't tested the other example with instance variable yet. Which one is best for performance?

Thanks
B
15
S
3
G
3
Posts: 93
Reputation: 1,466

Post » Thu Jul 31, 2014 11:23 pm

The simplest mechanism is to use the Fade behaviour, unless I misunderstand your requirement.
You do not have the required permissions to view the files attached to this post.
ImageImageImage
B
71
S
21
G
220
Posts: 3,648
Reputation: 123,725

Post » Thu Jul 31, 2014 11:26 pm

if projectile.count > X
pick nth(0) instance ---------destroy

that do it?
B
86
S
43
G
71
Posts: 601
Reputation: 43,619

Post » Thu Jul 31, 2014 11:39 pm

spacedoubt wrote:if projectile.count > X
pick nth(0) instance ---------destroy

that do it?


Works great, thanks
And thanks to blackhornet too.

But I still don't understand why I couldn't get the array to delete my projectiles.
B
15
S
3
G
3
Posts: 93
Reputation: 1,466

Post » Sat Dec 19, 2015 6:44 pm

spacedoubt wrote:if projectile.count > X
pick nth(0) instance ---------destroy

that do it?


That's a necroposting for sure, but i searched forums for my trouble and your reply worked just fine !
Just wanted to say "thank you" )
B
12
S
1
Posts: 24
Reputation: 611


Return to How do I....?

Who is online

Users browsing this forum: MadSpy and 3 guests