[Solved]How do I - Have the system pick the largest amount

0 favourites
  • 3 posts
From the Asset Store
Pick Up Items Sound effects for your game, Take them for a ride right now and you will worry no more.
  • I'm going to assume that I need to be using the System pick conditions, but I can't wrap my head around getting the system to pick "the best" out of all of the selections.

    I'm using "System pick sprite where sprite1 HP > sprite2 HP"

    and I'm also using "pick sprite1 Nth instance" to pick the first available one but....

    I can't wrap my mind around how I would get the system to choose the largest one.

    I imagine its something along the lines of.... "For every sprite1...." and maybe ... grab it's HP value, and set it to a Global Var HPVALUE_Max

    And then grab another sprite1, and if that value is larger than the previous, replace it... and repeat for all...

    Then go to the sprite1 who's HP = HPVALUE_MAX , and of course pick the Nth instance of it incase of multiple's ....?

    And then.... use that to "Pick the best" ?

    Sorry for my rambling, I think it helped to type it all out.

    But I still wonder, is this how you would do it? (Hello reader!)

    As usual, I'm just wondering if this is "pretty much correct" and I'm not looking something.

  • SwatHound

    there is a Pick Highest/lowest option under Instance Variables for an object...

    so, Sprite > Pick highest/lowest > choose highest and HP

    Another way would be

    System > For Each (ordered) > Sprite > Sprite.HP Descending then stop the loop after the first one...

    but you would only do it that way if you were looking for a value that wasn't an instance variable, like the Sprite with the highest Opacity, or Angle or some other attribute.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • SwatHound

    there is a Pick Highest/lowest option under Instance Variables for an object...

    so, Sprite > Pick highest/lowest > choose highest and HP

    Another way would be

    System > For Each (ordered) > Sprite > Sprite.HP Descending then stop the loop after the first one...

    but you would only do it that way if you were looking for a value that wasn't an instance variable, like the Sprite with the highest Opacity, or Angle or some other attribute.

    Ah hahaha. AND THIS IS WHY I ASK QUESTIONS!

    THANK YOU! LOL I never .... used that.. function.. haha.. lovely I see it now yes yes... I must have gone over that a thousand times.

    Thank you AllanR ...

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