How do I make Tile based pathfinding (+turn-based)?

0 favourites
  • 2 posts
From the Asset Store
Units do not overlap each other and use different ways if there are several free ways.
  • Hello,

    I've been trying to get tile movement and pathfinding to work together, also, entity should move only one tile at time after player have moved (I guess that could be called turn-based).

    For example: NPCs form Cataclysm, caves of Qud or some classic RPG games.

    I already have that time/turn system working and NPC will move one tile at time toward its target if it has vision to it.

    But I know that there will be cases where I need NPCs to chase targets, walk around objects or go investigate stuff that it didn't see.

    I thought I was clever, if I combine pathfinding and tile movement behavior and use pathfinding's angle of motion as control to which direction it tries to simulate tile movement, but it started moving back and forth between three tiles... I guess it didnt hit waypoints or something so it got stuck.

    Any tips have this should be done? (doesn't need to work with those behaviors)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I managed to solve this while ago, but just remembered this post and add answer here, incase someone else has this issue.

    In my case I made Tile based pathfinding so:

    When object finds path -> system repeat object.pathfinding.NodeCount times -> create pathnode(object) to position using object.Pathfinding.NodeXAt(loopindex) and NPCs.Pathfinding.NodeYAt(loopindex).

    After that, that NPC has path nodes to walk to, but not moving.

    Then every time its that NPCs turn, it moves toward pathnode using tilemovement.

    of course, there are bunch little details like node numbering so NPC knows which node it should walk to, and so on.

    I used example from one of the topics provided here... sadly, I didn't manage to find it just now.

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