How do I find the closest available with bool false?

0 favourites
  • 6 posts
From the Asset Store
Math questions appear quickly on the page, so you must respond quickly to get points!
  • I am making an RTS where I have indirect control over my humans and am having problems finding the nearest available resource as opposed to just the nearest available.

    Basically, if a human decides they want to chop a tree I mark it as claimed. Then if another human is looking for a tree to chop, they should find the closest tree that is not claimed. I think my problem is syntax, I am currently trying to add all the unclaimed to an array then sort by nearest but just can't seem to crack it.

    Thanks in advance for any advice, this has been driving me nuts for two days.

    Tagged:

  • Use the pick nearest condition followed by a pick by evaluate condition that checks for the boolean status. Or other way round.

  • hmm that doesn't seem to be working

    this is my current hierarchy, i am trying to find the closest "object" (purple square) to the green object "finder" with canBeGrabbed = true

    The purple square with the arrow has canBeGrabbed set to false, and when I run it nothing happens

  • Finder on created

    <tab> object compare bool canbegrabbed = true

    <tab> for each Object

    <tab><tab> Pick nearest object || Action: object set animation frame 1

    This should work but I am I work so I can't verify.

    If this works you can try it again without the for each... I don't know off the top of my head if it automatically checks all the 'objects' I think it might.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • wow, it was so simple! I guess I wasn't thinking about using the bool test going through all objects, I'm super used to looking for specific instances. This simple structure works, thanks crew!

  • Awesome, glad it helped :)

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