How do I fix my pathing with multiple "Pawns" going for one object

0 favourites
  • 4 posts
From the Asset Store
Hand-painted tiles, objects, animated objects, and background to build a colorful Mayan civilization environment.
  • Hello,

    I currently have it setup so that one "pawn" paths to a box, picks it up, puts it on a pallet, then repeats till all boxes are gone.

    Im using the "pick nearest" to select what box the pawn goes for.

    It works great with one pawn, but need to get it to work with multiple. Mostly having it so that when one pawn is going for a box, other pawns dont go for it, or stop going for it.

    Any help would be great,

    Thanks in advance :)

  • Never use "trigger once" with objects that have multiple instances! "Trigger once" doesn't work per instance, if the condition is true for one instance, all other instances will be ignored. So remove it from events 2 and 5.

    You should pick the nearest pawn On start of layout and set its state to "getbox".

    Also, add "Pathfinding is NOT moving" condition to event 5. Move event #6 from sub-event to make it top level event. In event #7 immediately change the status to something like "delivered", otherwise this pawn will try to find a path for delivery again.

    .

    You are using "state machine" code, when you are assigning different states to pawns and check their states on every tick. I am not a big fan of this method, but if you are planning to use it, you should be very careful with how and when you assign states. And again - never use "trigger once" with such events.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Thanks for the feedback!

    What would you recommend instead of the "states Machine" for pawns?

  • I prefer using mostly triggered events and Timer behavior (instead of Wait). Triggered events usually start with "On..." and they have a little green arrow icon on the event list.

    There is nothing wrong with using state variables, or a combination of both, but you need to be careful with when and how you change states. For example, on your screenshot in event 4 the Pawn after arriving will still have todo="getbox" for a full second. During this second it will probably try to find the path to the same box several times. Which may trigger the "On pathfinding arrived" event several times and mess the things up.

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