Pick a path by array

0 favourites
  • 1 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.
  • .CAPX: https://www.sugarsync.com/pf/D6025908_4317202_6734583

    FYI: I am using the latest beta.

    Yes, friends! It's me...you're highly complicated, verbose, confused game developer.

    This time around, I'm working on setting up a patrol system for my enemies. When they aren't chasing the player around, they're "walking" between "patrol nodes" at intersections on the map. For each patrol node, I have 1 to 4 instances of directional nodes. These will be randomly (for the time being) selected to determine which direction the enemy will patrol next...always towards another patrol node.

    What I need to do is test for each directional node that it is overlapping/touching the patrol node. Every directional node will overlap a patrol node, so it's a matter of WHICH one. To solve that problem, every patrol node has an instance of an array contained with it.

    When it is detected that a certain directional node is overlapping its mutual patrol node, the IID of that directional node is pushed into the array to be referenced a moment later.

    This is the Event/Action set-up I have at the moment...clearly it needs refinement or I wouldn't be requesting help! LOL


    SYSTEM For "NodePatrol" from 0 to DirectionalNode.Count-1

    SYSTEM Pick DirectionalNode instance loopindex("NodePatrol")

    DirectionalNode Is overlapping PatrolNode


    NodeCompassArray Push front DirectionalNode.IID on X axis

    I am thinking it might help that I also pick the nearest instance for each Patrol Node to be sure the right array is accessed.

    Now, this has met with SOME success, it seems. IIDs are getting pushed into the array instances appropriately, but repeatedly instead of ONCE (which is what the For loopindex is trying to answer). Each array instance is 4 cells in width with initial values of "A" (so I can determine that an IID of 0 is actually being stored and not simply the default value of an array cell). So if three Directional Nodes surround a Patrol Node, the array should only have 3 values in it...the fourth remaining "A". But there are times when all four cells receive a value...or receive a value that it shouldn't (like an IID that isn't actually touching the respective Patrol Node).

    I need to be sure I get this worked out or I made end up sending my enemy on a patrol straight through a WALL.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)