Enemy Pathfinding breaks when player is in different region

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • I tried to implement a system where the player can unlock different regions by opening doors with collected crystals.

    One of the things I am trying to achieve is to have enemy spawners only to be created within unlocked regions. I am currently establishing which region is which using tilemaps.

    The problem I am currently facing is that when moving the player to a different region when there are no enemies spawned, the newly spawned enemies will just stay still unless the player is in the same region as the enemies.

    The desired outcome is to have the enemies follow the player all around.

    C3 File:

    drive.google.com/file/d/1eStuFx0aUV7-FmRi13C38NuQwS6oual2/view

  • What you're describing I can't recreate, for me the enemies follow you everywhere.

  • Sorry about the late reply. Life happened and I couldn't check this forum or work on this project for a while.

    I recorded a video where I replicated the bug and explained what happened. Hopefully, it should be clearer this way.

    youtube.com/watch

  • Now I look at it more closely, you will know more about it than me. This project doesn't make use of standard pathfinding events and instead physics which is rarely used for top down game.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I took a look too. I'm 100% sure that the problem is that the enemies in the previous room can't find a path to the player, hence they get stuck in place.

    I don't really know how Construct handles pathfinding maps between instances of the same object type, but I suppose that after a door is destroyed, all enemies still use the old map with the door still present.

    I fixed your issue by adding a global boolean DoorRecentlyUnlocked which I set to true when a door is destroyed. Then, when an enemy is created (using On created enemies), if DoorRecentlyUnlocked is true I update the whole obstacle map using Regenerate pathfinding obstacle map and set DoorRecentlyUnlocked to false prevent unnecessary calculations. Give it a try :)

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