Issues narrowing picking object by nearest based on object layer.

  • AIM: To get the game to only pick the object, and tile, that is not on the "Lookout" layer when it picks the nearest object. Pieces should move tile by tile towards the opponent's closest piece (cardsnpieces).

    BACKGROUND: This is for building an AI opponent who will play on their side of the board. I have to make this work by an exhibition on Monday (along with other AI things like attacking which I haven't begun yet).

    I have tried:

    - Placing the layer condition under the pick nearest. This results in no pieces moving.

    - Placing the pick nearest on a sub-event. This results in pieces moving randomly.

    PLEASE FIND IMAGE TO EVENTS BELOW

    I don't understand how the forum adding images works.

    i.imgur.com/3GPLdoc.png

  • I think you need to add another event - "For each EnemyCardnPieces" between events 767 and 768.

    Otherwise in event 768 you are picking just one CardsnPieces instance (closest to the first picked instance of EnemyCardnPieces).

    Also, I don't know what's the situation with layers in your game. If these objects are on layers with different parallax, you might need to re-calculate their coordinates..

  • Fixed using for each AFTER the pick nearest, with the right sub-eventing.

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Not sure if this is correct. "For each" should be before "Pick nearest".

    See this picture.

    If event 767 picks 3 red instances, then "Pick nearest" event will pick only one green instance, nearest to the first only red instance. (although there may be other green instances located closer to other red instances)

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