Checking for Destroyed Objects.

0 favourites
  • 5 posts
From the Asset Store
Welcome! I-Spy (Hidden objects) is an educational puzzle that is more than just seek-and-find activities.
  • I want to know if there is a condition which checks if all instances of an object are destroyed.

    I'm trying to set AI for my enemies to hunt down specific NPC classes one by one in order,

    eg: | System: Every tick | Enemy1: Set Angle Toward: NPC1.X NPC1.Y

         | NPC1: is Alive     |     

       

    Alive: is a boolean which detects if the NPC1 health is equal to or below zero.

    What I want it to do, is after all instances of NPC1 are destroyed (Alive = False) My enemy AI switches to follow NPC2.

    I tried by doing;

        | System: Every tick | Enemy1: Set Angle Toward: NPC2.X NPC2.Y

        | NPC1: X is Alive   | (Inverted)

    I'm not sure why this didn't work, since I have another event in my sheet which says:

        |NPC1: X is Alive| NPC1: Destroy.

    And that works. But when I add the boolean condition onto another it seems to not work

    On a separate question, is there a way to;

    Set Angle Away From Position?

    Before you say "invert the values" I want to use this to set my "NPC's" to run away from the Enemy's. ATM I just have them all running in Random(360) directions. Since inverting the values only works for unchanging values, is their an equation or action or something that inverts the values for me?

  • I want to know if there is a condition which checks if all instances of an object are destroyed.

    From system-> compare two values condition: sprite.count = 0. That would check if any instances of the object exist. sprite.count is built-in variable that keeps count of how many instances of an object exist.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thank you so much. That worked perfect.

    Any Idea about my other question?

    On a separate question, is there a way to;

    Set Angle Away From Position?

    Before you say "invert the values" I want to use this to set my "NPC's" to run away from the Enemy's. ATM I just have them all running in Random(360) directions. Since inverting the values only works for unchanging values, is their an equation or action or something that inverts the values for me?

  • On a separate question, is there a way to;

    Set Angle Away From Position?

    Before you say "invert the values" I want to use this to set my "NPC's" to run away from the Enemy's. ATM I just have them all running in Random(360) directions. Since inverting the values only works for unchanging values, is their an equation or action or something that inverts the values for me?

    Don't know what behavior (if any) you use for movement, but in general this should work:

    enemy set angle towards position: player x,y

    enemy set angle: enemy.angle-180

    Or alternatively, if you prefer single action:

    enemy set angle: angle(enemy.x, enemy.x, player.x, player.y) - 180

  • Thanks a lot for the Sprite.count=0 trick !

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