How do I make enemy reach a full stop after losing sight of player?

0 favourites
  • 5 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hi,

    I have an enemy that pathfinds to player if player is within a certain distance of the enemy, and the enemy also has the line of sight behavior to allow for it to aim towards the player to throw missiles.

    Right now when the distance between player and enemy for which pathfinding and line of sight applies is exceeded, the enemy starts to walk back and forth between two grid points and the animation is also playing.

    I have tried to solve the problen by saying that if the maximum distance for triggering pathfinding is exceeded as well as the line of sight is lost, stop animation and stop pathfinding. However, with this event implemented the enemy still behaves as described above.

    What other approach could I take to solve this problem?

  • So the enemy is finding path in two different events ? If enemy and player are within a certain distance find path and also if the enemy has line of sight then find path. So you are saying that in your game if the enemy is a certain distance from the player but does not have line of sight, it will still move towards the player? I mean the design seems kind of convoluted, why not just use one or the other instead of both ? Your title refers to 'losing sight' only so maybe sticking with LOS is the better way.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Hi lionz,

    I went with the approach of using both pathfinding and line of sight because I am using pathfinding to simulate 4 direction only tile movement. Maybe this 4 direction simulation could have been done with line of sight?

    But, regardless if I use both pathfinding and line of sight or not, I feel there should be a way to make the enemy reach a complete stop when the distance between player and enemey for pathfinding/line of sight is exceeded?

  • No problem with using pathfinding and LOS, I am referring to using LOS and a distance check. Maybe by distance you meant when they are out of range of LOS so it's the same thing? Then yes it should work, you can say when enemy does not have LOS of the player, Stop pathfinding. Feel free to post a screenshot of those events.

  • Now I understand what you meant. Yeah, I could do some sorting out and go with either only compare distance or LOS. However, what solved my problem with making the enemy reach a complete stop was to set tile movement to disabled.

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