How do I pick an object that has the highest value at a variable?

0 favourites
  • 9 posts
From the Asset Store
Easily store, modify, read and manipulate colors with Color Variables!
  • doing battle. heroe attacks highest att stat enemy.

    if there an easy way to pick an instance of an object with the highest att stat?

    yeah i could make a loop, to run down from 1000-0, and stop when the object att stat = the loop.

    but.. honestly, attack could be in the 100's of thousands.

  • op. there it is.

    pick by highest lowest

    sorry to bother you all

  • nope, i need to rephrase it.

    i need to pick the highest attack.

    but, out of objects that have a position variable between 11-20.

    to explain. i have 10 heroes, 10 enemies.

    each with a variable position. enemies are 11-20

    so, on attacking, the attack animation needs to spawn on the strongest enemy.

    i need to pick highest attack stat, where position is above 10, less than 21

  • You can use a loop but not the one you mentioned, there is a system 'for each(ordered)' you can run through each enemy ordered by attack stat from high to low, so the first one it finds is the one you want.

  • good shout lionz.

    turns out, it really wasnt hard just to set all enemies to just be a difforent object.

    there was a reason i set them to all be the same object... im sure it will come bite me in the arse later.

    but. what i have works now.

    pick highest is fine when the enemy is different object

  • Oh I have never used pick highest but this would also work. I thought it was to do with z order :D

    You can use pick highest attack stat and before this have a condition that the enemy stat is greater than 10, less than 21. This will pick the highest of the 'remaining' enemy instances.

    In general I think the enemies should be different objects or you end up with a lot of animations on one object. If you want to pick all enemy objects together later you can use a Family of enemies.

  • sigh.

    targetting highest attack if fine

    but, now i need lowest hp... when they are dead, their hp is 0... cant target a dead man

    i need to beable to add another condition.. i dont think that works..

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • like in the previous response you can use the same way, condition that hp is greater than 0, then pick lowest hp.

  • yup!!! super happy that works.

    now i can target specific targets.

    thanks for the quick responses. ill have battle done by today

    ...even if that means ill have to go back into blender to do more animations... oof... at least im getting good at it

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