Skip to main content

Search

How can I sort all of the objects in a zone?

  • Mm QA Team

    If you simply want to know which is the closest enemy to the player (or something else) you can do this.
    You need a trigger zone set to detect Tag’s called distance which has zone size 0 and falloff size big enough to encompass your enemies to check the distance. The closest Tag called distance within the falloff will have the highest value.
    On the enemies you have a Tag called Distance wired to a Gate gadget set to interrupt. Only one Gate gadget of the same name can be active at a time. As the tags move closer to the centre of the zone their value increases. The closest tag will have the highest value and its gate will become the active Gate
    You can then have a microchip activated by the Gate with A Tag saying closest target or whatever logic you want the closest target to have.
    Hope that helps get you started.
    K

  • StankyDino

    That really does help.
    So to find the closest tag that is also in line of sight, I should have each potential target also raycast to the origin and only have the gate open when it connects.

    Cool.

    This is for a chain lightning spell, so if you have any other advice, I'm all ears for autonomous algorithms. If that's too involved to get into, then thanks anyway!

Please sign in to leave a comment.