How do I Check for both players being at 0 health? [Solved]

Not favoritedFavorited Favorited 0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Sometimes I run into snags like this in C3 where I feel like my code should be working and isn't. I usually come to find out it's something with how C3 works that I didnt' understand.

    Anyway, I have 2 players on screen. Using the same sprites, but they have an instance variable I use to perform checks. This is the first time I have run into an issue as I want to check if both players health are equal to or less than 0. Here is my code that doesn't work.

    - System -> Pick sprite by evalutating sprite.actorID = 1

    --- System -> sprite.health <= 0

    ----- System -> Pick sprite by evaluating sprite.actorID = 2

    ------- System sprite.health <= 0 -----> Browser Alert "Game Over"

    In my mind it's picking the sprite for actor 1, checking if it's health is <= 0, if it is, it's then check the same for actor2. If that is also 0, game over.

    Thanks.

    Tagged:

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • It is a Construct thing yes with picking. When you pick the first sprite by var=1 it narrows the pool of sprites to pick from to that one only, so it won't find the other sprite in that same event.

    There is a way to do it in the same event but it can sound a little convoluted, after picking sprite.var=1 has 0 health, in the next sub event you can use 'pick all sprites' again to open up the pool of sprites to all, then in the next sub event you can pick sprite.var=2 has 0 health as well so then when you hit this end condition I think you will have what you wanted.

    Also an important thing, I don't think it will work anyway with system conditions for picking instances. Use the actual sprite object conditions and not system.

  • It is a Construct thing yes with picking. When you pick the first sprite by var=1 it narrows the pool of sprites to pick from to that one only, so it won't find the other sprite in that same event.

    There is a way to do it in the same event but it can sound a little convoluted, after picking sprite.var=1 has 0 health, in the next sub event you can use 'pick all sprites' again to open up the pool of sprites to all, then in the next sub event you can pick sprite.var=2 has 0 health as well so then when you hit this end condition I think you will have what you wanted.

    Also an important thing, I don't think it will work anyway with system conditions for picking instances. Use the actual sprite object conditions and not system.

    That makes sense and it worked. I simply did this:

    - System -> Pick sprite by evalutating sprite.actorID = 1

    --- System -> sprite.health <= 0

    ----- System -> Pick All sprite

    ------- System -> Pick sprite by evaluating sprite.actorID = 2

    --------- System sprite.health <= 0 -----> Browser Alert "Game Over"

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