How do I Destroy Recent Bullet

Get help using Construct 2

Post » Mon Jan 11, 2016 10:45 pm

Alright, I'll tell you the events.

Here's the key:

Fireball1 and 2 are particle effects with the bullet behavior. They are each spawned on top of the other, so they're always together. Once they're spawned, "FireDestroy" will be pinned to one of 'em. Once FireDestroy collides with the tilemap, the particles will fade out and be destroyed.

FIREBALL FUNCTION:

On X key pressed : Set animation to "Fireball" (play from beginning)
Player : Start Ignoring Platform user input.
: Set "Player Animations" group deactivated.

If animation "Fireball" is playing:

Animation frame = 1
Trigger Once : Spawn Fireball1 on Layer 5 ( Player image Point 1 )
: Spawn Fireball 2 on Layer 5 ( Player image Point 1 )
: Pin FireDestroy to Fireball
: Set Fireball1 Bullet Angle of Motion to 270 Degrees
: Set Fireball2 Bullet Angle of Motion to 270 Degrees

On animation "Fireball" finished: Stop Ignoring Platform user input.
Set "Player Animations" activated.

FIREBALL DESTROY:

(This will fade the fireball out over-time, so it doesn't go all the way to the end of the map and further, also makes it look nice)
Fireball1 On created: Wait 1 Second
Fireball1: Start Fade
Fireball2 On created: Wait 1 Second
Fireball2: Start Fade

(This is when the fireball is destroyed upon colliding with Tilemap)
FireballDestroy - On collision with TILEMAP: Set Fireball1 Bullet Disabled
: Set Fireball2 Bullet Disabled
: Fireball1 Start Fade
: Fireball2 Start Fade
: Destroy FireDestroy

(The bullet is destroyed after fade)
B
23
S
10
G
1
Posts: 153
Reputation: 2,635

Post » Tue Jan 12, 2016 7:20 am

Your not actually picking anything specific with the on collision condition, your simply picking all instances of Fireball1 and Fireball2...

If you set an X,Y at collision point and used a "is closest instance to X,Y var" condition as well, then it would pick the one that collided...

Also you could make an instance var in Fireball1-2 called say... explode=0 and set it to 1 on collision for the colliding instance and then condition explode=1 when destroying...

You could also look into containers and put both Fireball1 and Fireball2 into a container and then "pick" the whole container to fade/destroy and that should eliminate the problem as well.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
54
S
15
G
8
Posts: 608
Reputation: 8,767

Post » Tue Jan 12, 2016 7:48 am

want to destroy the oldest:

for each fireball ordered by fireball.iid (ascending): destroy fireball, stop loop


want to destroy the newest:

for each fireball ordered by fireball.iid (descending): destroy fireball, stop loop


But I guess it would be easier and make more sense to give them a timer or something and destroy them after a specific time or whatever, oh well.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 787
Reputation: 3,786

Post » Tue Jan 12, 2016 9:13 am

chrisinfinger wrote:Your not actually picking anything specific with the on collision condition, your simply picking all instances of Fireball1 and Fireball2...

If you set an X,Y at collision point and used a "is closest instance to X,Y var" condition as well, then it would pick the one that collided...

Also you could make an instance var in Fireball1-2 called say... explode=0 and set it to 1 on collision for the colliding instance and then condition explode=1 when destroying...

You could also look into containers and put both Fireball1 and Fireball2 into a container and then "pick" the whole container to fade/destroy and that should eliminate the problem as well.


Can you please go into more detail with the X,Y Collision Point suggestion and the Variable suggestion? I'm having trouble following.
B
23
S
10
G
1
Posts: 153
Reputation: 2,635

Post » Tue Jan 12, 2016 4:26 pm

Create two variables, say impactX and impactY and in the event where your fireball1/2 make collision with tilemap have it store the fireball1's fireball1.X and fireball1.Y to the variables X,Y. Now in your destroy events use condition choose fireball1/2 instance closest to impactX and impactY... but for the work the instance variable is easier...

Create an instance variable inside the particle (on main layout in left side properties when particle is selected). We will call the variable explode=0. Now in your collision event for the fireball have it set explode=1. Now all you need to do is in your destroy event condition explode=1 and only those fireballs that have collided will fade/destroy.

Since you use two particle objects pinned together you will need to make an explode=0 in each and change both to explode=1 unless you put them in a container and then use the variable on the container.. but containers can do more than this and are well worth the time learning.
Check out my completed games on the Arcade! Capt. Doe Save the Universe! & Clicker Wizard!
B
54
S
15
G
8
Posts: 608
Reputation: 8,767

Post » Sat Jan 16, 2016 10:44 am

I can barely understand with the lack of punctuation and details in your replies :/

Create two variables in what?
How does any of this involve the FireDestroy sprite?
For some reason, I'm unable to choose Particle - On collision with object, the option isn't there, so the only way to do this is to test collision with a sprite that is pinned to the particles.
But, when I make an event "FireDestroy on collision with TileMap - Set 1 to instance variable; explode on Fireball 1 and Fireball 2" it applies the variable to every single particle's instance variable currently on the screen.
B
23
S
10
G
1
Posts: 153
Reputation: 2,635

Post » Sat Jan 16, 2016 11:11 am

August 2015 - I misplaced a lot of links - I will try to find backups and repost. If You find a post that interests please reply to post with @rampackwobble and I will get a nudge!

If you find my posts useful please consider donating something to a local charity or to the http://www.mndassociation.org/
B
64
S
33
G
47
Posts: 1,194
Reputation: 30,782

Post » Sat Jan 16, 2016 10:25 pm

RamPackWobble wrote:any good as a starting point?

https://www.dropbox.com/s/9sxapz6haa0p4 ... .capx?dl=0

Thank you very much, it works perfectly. ^-^
It's working now!
B
23
S
10
G
1
Posts: 153
Reputation: 2,635

Previous

Return to How do I....?

Who is online

Users browsing this forum: marcoscodas, raulcg1981 and 13 guests