If 5 bullets on screen, destroy the oldest bullet

  • Hi guys,

    I have no idea how to do this (title).

    I also don't understand how I can refer to cloned objects in general (like 1 copy of a bullet, or one instance of an enemy)

    I know this will be super simple! Thanks!

  • Since the oldest bullet would probably have either the lowest zorder or the lowest UID you could sort by either and pick the first object (Pick nth instance action) for example.

  • Since the oldest bullet would probably have either the lowest zorder or the lowest UID you could sort by either and pick the first object (Pick nth instance action) for example.

    Do you mind giving me an example?

    I still don't know how to destroy a specific bullet.

    I can use a global variable to count the bullets on screen and destroy if there are more than 4, but this destroys ALL bullets.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Alright, adapted a little example for you - we "pick" all the bullets on screen and compare their count - if it's higher than what you need we pick the "oldest" bullet (because we know it's going to be the "lowest" one and destroy it.

    Some event ninja will probably come by and offer a more elegant solution, but this works.

  • Thanks very much, that works great.

    I didn't know about "PickedCount"

    I guess it's time for me to re-read the manual, more carefully this time! Thanks again.

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