How do I Destroy Recent Bullet

0 favourites
From the Asset Store
This pack contains 10 types of bullet effects, with different shapes and colors.
  • I have a fireball set to be destroyed upon colliding with the Tilemap.

    Unfortunately, if there's more than one fireball on the screen, it'll destroy every single one of them.

    How do I fix this? I can't pick by UID because they're spawned when the player presses a button, so that's impossible as far as I know.

  • You must condition out all the others.. read the manual under "picking" instances of an object.

    You will need to find a condition that is only true for the one(s) you want destroyed so only it/they meet the condition and are destroyed.

  • Any ideas on what the condition could possibly be?

    The player shoots fireballs by pressing a button, so they're all the same, like I said. ^-^

  • I fixed it by choosing "Pick Furthest to Player.X & Player.Y"

    Taken care of.

  • Nevermind, doesn't work. My bad : P

  • On Fireball Collison with Tilemap -> Destroy Fireball

    Doesn't this work?

  • Nevermind, doesn't work. My bad : P

    Do not use the Pick furthest condition in this situation for it is not a certain that it will be destroyed in the right place and in the right time.

    Use the on collision condition and destroy it..

    On collision of object Bullet to Tilemap1 then

    ----> Destroy Bullet

    :This will ensure success in timing and location:

  • That's exactly how it is, except in my case, I have the bullet to fade out upon colliding with the tilemap, which causes all fireballs on the screen to fade out. Any ideas?

    (it gets destroyed after fade-out in the behavior settings)

  • That's exactly how it is, except in my case, I have the bullet to fade out upon colliding with the tilemap, which causes all fireballs on the screen to fade out. Any ideas?

    (it gets destroyed after fade-out in the behavior settings)

    I really don't know what you mean by that, usually collisions do the trick. Can you provide more details or better yet a sample of .capx file.

  • That's exactly how it is, except in my case, I have the bullet to fade out upon colliding with the tilemap, which causes all fireballs on the screen to fade out. Any ideas?

    (it gets destroyed after fade-out in the behavior settings)

    There seems to be something wrong with the picking..

    I'm guessing you are setting a variable on collision and checking this with a system compare action, which would be the issue..

    Please share your events and/or capx so this very simple issue can be solved..

    (by the way, ofcourse you can use uid with created objects)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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)

  • 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.

  • 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.

  • 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.

  • 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.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)