How do I Make my enemies chase the player with pathfinding.

0 favourites
From the Asset Store
Players follower. use it for anything which follows the player
  • Hello there,

    I'm trying to figure out with the official Pathfinding plugin, How to constantly and smoothly make some enemies follow an object, without getting out the path, i'm trying a lot of tricks but nothing is a solid solution, I tried with stop and then keep following with the every 0.1 seconds condition, but nothing, even a guy tried to help me in another issue but this ain't working, I'll be glad if someone would guide me in HOW to do it, because I find quite weird that the official plugin could not handle this kind of behaviour I need.

    I'm going to attach this .capx that could help anyone to try and see what I'm trying.

    https://www.dropbox.com/s/ywset1901frys ... .capx?dl=0

    If it's the size, well, let's try something else, but true is that the game's resolution is 16x16 and it's one of the most standard, I'm pretty positive that someone must know how to handle this!

    this community is awesome and I admire lot of people here, I learned a lot in the forum and it helped me to figure out a lot of things in my games, so I hope this will be fixed and solved too.

    Regards.

  • Thank you for quick response, I checked in my main Game and that made that my enemies follow the path correctly!! but, however, I'm facing another problem. they're not actually chasing me smoothly, but they go to the last place I was UNTILL they arrive. any trick for it? you can also see the result in the capx you attached, any hint?

    EDIT: Any routine, timer, trigger I try gets me the same result that you fixed commenting the every x seconds and putting those 2 conditions. halp

  • I don't really have much experience with the pathfinding behaviour.. It seems kinda tricky to work with.. Anyway, I made another try, see if that's any better:

    https://drive.google.com/open?id=0B1Aaz ... nRQVm92THc

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Heya Space, thank you so much for your .capx, don't worry if you don't have much experiencie with this, you've helped! still, maybe someone could help us figuring out this because isn't perfectly working, because your last try didn't change that much the problem . I'm going to show you deeply with these gifs:

    the solution you made that actually makes the enemies follow the path correctly, but...

    The enemies has like with a mental delay.

    And what I would want to:

    AND you can see that this try I made, has the pathfinding errors we encountered in my first .capx

    The red zone is obstacle map, to let you know that they're NOT following it properly.

    I made that try with the typical every 0.1 seconds -> Find path and on path found -> Move along path

  • *Bump* I really need some help over here !

  • *bump ...

  • *bump ...

  • I haven't tried any of the game version yet but looking at spacedoubt gif the movement seems more suitable than your idea. I mean that technically it is not what you want to achieve but it might look more realistic since if you have a gun you don't want to go on melee but on the contrary you want to follow the enemy but still try to get as much cover as possible. That 'error' seems like they want to stay somehow away. I need anyway to see the game to test the real behavior. Different story if your enemies have a melee weapon, in that case your solution might be better.

  • Hello Biim and thanks for your point of view, the first Gif I made yea, is from spacedoubt solution, I'm not quite sure if this kind of behaviour will suit for the entire game since this time, okay, the seemed to be like cover, but it won't be like this all the time maybe, so it could appear that the enemies have some lag or stuff like that.

    and indeed, we also got melee enemies.

    so my scope is neccesary too (I woulnd't say solution since I don't have it, if you see the second gif, you could see how the enmies doesn't follow the path correctly, getting though walls).

  • I got it, I will try to have a look at it later on. Hopefully you can find a solution early

  • Okay.. so I THINK I can explain your problem, but I don't know the solution off the top of my head.

    In my examples, the pathfinding is not working how you want.

    In your example, the pathfinding IS WORKING how you want.

    However, collisions are not. I've seen people have this problem with bullet behaviour. I'll explain:

    Let's say your solid object is 8 pixels wide. let's say a bullet heads toward that object with a speed of 20 px/tic..

    This can result in the bullet jumping entirely over the solid, so no collision is actually registered.

    I believe something similar is happening to your pathfinders. Maybe when they turn or something, they become close enough to the other side of the solid, that they end up there.

    Honestly, I'm not completely positive on that.. (I could be completely wrong) but seeing as you don't seem to getting much help (rare around here), I figured I'd share my theory.. Hope it helps!

  • Thank you so much man for posting your theory, and exactly:

    My .capx is WORKING as I want to, however, the collisions on the obstacle of the pathfinder are not.

    Your .capx shows the pathfinding working but not how I want to (a continuosly chase it's what I need.)

    Something that might be causing problem is the resolution and could fit with your teory, since I DID NOT have this problem back then when I created the same system in a 32 cell size. we're reworking the game to a simpler resolution and that ended up using tilesets 16x16, that indeed, need a pathfinding map of 16 cell size.

    Wish I could just get help from Ashley or R0J0hound, maybe they know how could I get a workaround for this!

  • This is actually an incredibly difficult problem. I would recommend not trying to handle collisions with the walls, because then you open a new can of worms where objects constantly get stuck.

    The main problem is the rotate speed is relatively low compared to the acceleration and speed. So the enemies can only turn in very wide arcs, while chasing you down a narrow corridor with very tight turns and corners. The pathfinding behavior does try to slow down objects so they can make the turn, but I guess it doesn't work that well, and if it did, your enemies would spend most of their time going slowly to make sure they can make the tight turns. This would probably spoil the game as they would easily get left behind.

    Basically if you set all of them to have a rotate speed of 3600 they follow the player just fine, but sticking to 45 degree angles. You probably just want to find the best rotate speed to compromise.

  • Ashley , thank you for answering and posting the solution.

    Indeed, that was the problem! the rotation speed. since my enemies are fast, they needed a highger rotation that ended up solving the problem. or at least that's what I think and I'm seeing, you can look it by yourself at this .capx I made with the rotation fixed! so anyone who went into this problem could get this .capx and see that actually it has a solution:

    https://www.dropbox.com/s/wlbd7ugm4tch5 ... .capx?dl=0

    Also, I've implemented a LOS to see that you won't be actually seeing them rotating that fast because you could adjust it manually by setting rotating object to no in their pathfinding properties.

    and in this gif I'm showing the fact that my guys are following properly now. <img src="{SMILIES_PATH}/icon_e_biggrin.gif" alt=":D" title="Very Happy">!

    Thank you guys! you might want to pin this to the How do I FAQ. I didn't see something like this in that place.

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