How do I automate enemy movement with tile movement constraints?

Not favoritedFavorited Favorited 0 favourites
  • 8 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • I plan to do something like Pac-Man's ghosts' AI in terms of movement fluidity, but using tile movement behavior instead of bullet behavior. I already looked into how "Eat 'em All" does it but came up short, as it uses bullet behavior instead of tile movement.

    Any help, as ever, is appreciated.

  • You need to locate a specific tile and find a path to it. I would use the Pathfinding and MoveTo behaviors together. First, find the path to the target location, and then (On Path Find) use MoveTo Move along Pathfinding path. This approach works well if the map is designed like a corridor, otherwise, enemy will cut corners and move in diagonal. (I don't know how to have to move only in 4 directions, turning off diagonal movement doesn't help)

    Also you can try to calculate tile where you want to move enemy and then connect pathfinding to MoveTo(tilemap.TileToPositionX(tileX), tilemap.TileToPositionY(tileY)). Maybe someone more experienced will correct me or will have a better and more elegant solution...

  • I would also use Pathfinding+MoveTo. MoveTo is a lot easier to deal with than TileMovement.

    Configure the pathfinding grid correctly, disable acceleration/deceleration in MoveTo. Find path, move to the first node on the path. On arrived - move to the second node and so on. You can use tilemap expressions like SnapX/SnapY to find the exact center of the destination tile.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I would also use Pathfinding+MoveTo. MoveTo is a lot easier to deal with than TileMovement.

    Configure the pathfinding grid correctly, disable acceleration/deceleration in MoveTo. Find path, move to the first node on the path. On arrived - move to the second node and so on. You can use tilemap expressions like SnapX/SnapY to find the exact center of the destination tile.

    Interesting. How would I go about configuring the pathfinding grid?

  • By reading the official manual! :)

    Admittedly helpful.

    Ok, given that, and with the assumption that it's all set up correctly... my character still doesn't move. What am I doing wrong here?

    If this helps, here's a basic rendition of my layout:

    The red is the border (Obstacle), the orange are the cells that spawn the characters (currently none since the focus is on the enemy sprite), and the brown is the enemy sprite.

  • First of all - never use "Trigger once" condition with objects that have multiple instances.

    You need to make sure that your ghosts can actually find a path. The easiest way is to add some visual feedback. For example:

    Ghost On path found → Ghost set opacity to 100
    Ghost On failed to find path → Ghost set opacity to 30
    

    If you see that them turning semi-transparent, try tweaking the pathfinding settings, such as cell size or padding.

    Once you fix that problem, I suggest you use MoveTo behavior for movement, it's more accurate. And it has "Move along pathfinding path" action.

  • First of all - never use "Trigger once" condition with objects that have multiple instances.

    Deleted that part now.

    You need to make sure that your ghosts can actually find a path. The easiest way is to add some visual feedback. For example:

    > Ghost On path found → Ghost set opacity to 100
    Ghost On failed to find path → Ghost set opacity to 30
    

    If you see that them turning semi-transparent, try tweaking the pathfinding settings, such as cell size or padding.

    No semi-transparency happening here.

    Once you fix that problem, I suggest you use MoveTo behavior for movement, it's more accurate. And it has "Move along pathfinding path" action.

    I figured out that the reason it isn't moving is because the MoveTo had "Stop on Solids" active.

    I thought that was the way to ensure that the obstacle would act as such, but I'm guessing the size of the blocks didn't allow any movement at all.

    Now that "Stop on Solids" is no longer active, how would I make sure the ghostblock doesn't ever overlap the red?

    Edit: Figured out I had the numbers halved on the grid setup. Now that's working as intended, and there's no overlap because I added cost to the pathfinding overlapping red.

    Now the issue is in perpetual motion. What I've done so far is made a target move randomly between cell positions thusly:

    I want to figure out how to make it so that when ghostblock arrives at Target, the target changes location.

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