4 Pathfinding / Player Follow Examples (Platforming & Top-Down)

This seems like a cool concept! I find it difficult to have enemies navigate around walls like that, so I’d be interested in seeing where this goes.

2 Likes


Understandable, have a great day.

1 Like

once the smilies notice you, they never stop chasing, even when your far out of sight

other than that this is really good

2 Likes

the top down one

1 Like

Which top down one, the one with a player or the target one?
I’m assuming the one with a target as the player one already has angular velocity.
If that’s the case, I think what you’re asking for is called Any-Angle pathfinding, and it’s a lot more complex then the simple Breadth-First Search employed here. Basically it would entail checking every single possible angle at every single point, and though there are optimizations, I don’t know that it’s possible at the moment in Flowlab (with reasonable performance anyway).

However if all you want is for the Characters to move with angular velocity and you don’t care about their path being all right angles, if you check the game now I’ve switched them to smoothly rotate between angles while they move; is this sort of what you mean?

2 Likes

Thanks for the feedback, and you’re exactly right, they never stop following you (unless they somehow reach a place the player hasn’t been in yet).
An NPC “forgetfulness” mechanic would be pretty simple to add, whether it’s to forget about the player after a certain time chasing them, or after a certain time not seeing them, or after they get a certain distance away, etc.
But I feel like this is something to be added on a per-game basis.

2 Likes

Ron from FNF
image
image

2 Likes

Bruh I don’t play fnf and never played any mods before but ok

1 Like

No, I meant the comparison.

2 Likes

I see now; you had or still have a different idea. I understand.

2 Likes

The recent help request reminded me that I have actually made a better / more optimized version of my top-down pathfinding:

The difference isn’t very noticeable just playing it, but the code is much better organized and streamlined, so it runs much better overall.

6 Likes

Wow, this is insane. The best pathfinder I’ve every seen, lol.

2 Likes

1st Game: A little while ago, I created this top-down pathfinding system that does NOT use ANY waypoints or ANY extra spawned objects (all the pathfinding is calculated in the brain and any target objects). It does require a bit of extra code in the walls and a separate parent object for . . . everything (i.e. the AI, Walls, and Target are all parented to 1 object).
2nd Game: Then I had an idea for how to turn the pathfinding into ANY-ANGLE pathfinding, meaning the AI’s find the shortest path to the target at any angle at all, not just multiples of 90 degrees.
I have not finished refining these games yet, but I figured (since I’m not actively working on these right this moment) that I might as well share what I’ve got so far. So the performance and code in general are not yet as optimized as they could be, but the basic system is in place and works. (Ironically, the any-angle pathfinding is more optimized than the regular breadth-first search version.) I am going to work on these more in the future.
For now, feel free to take the code and run with it. If you’re interested in how something works, just ask, though I can’t guarantee I’ll have time to give a full, in-depth explanation.

9 Likes

I love this so much!
I’ve been hyping up brickccentric with this example so much lately, it’s truly amazing, and I’m super excited to use it.

Here are some screenshots from when I first tried it - To Hype you up:
Performance :ok_hand: :sparkles:


It goes through this part!
image

5 Likes

O my god this is insane!! Any angle pathfinding??? I wouldn’t even know how to start! Pls explain it a bit

5 Likes

Ok, do you know how breadth-first search works? This uses a breadth-first search but then the AI does line-of-sight checks while moving, to determine the waypoint that is closest to the target but that the AI can still see from its position.
Usually in a breadth-first search you would store some kind of direction value for each checked position that tells you the direction it was checked from, but this doesn’t store any direction values at all.
Instead, the order in which positions are checked tells you how close they are to the target—if a position is checked and found empty then it’s added to a list, and since each position is checked before expanding its neighbors, positions closer to the target will be closer to the start of the list than positions further from the target.
Then the AI simply searches the listed positions in order, and the first position it can see, it stops checking and aims for that one.

1 Like

yeah, I’ve done my own breadth search pathfinding before. So are you using raycasts to see if the AI can still see it from it’s position? How do you tell if it can see that position?

2 Likes

Yes, the AI’s send a raycast out to the position, with the ray set to check for wall objects. Since the ray only extends the distance between the AI and the specific position, a Miss output means there are no walls between the AI and the specific position (so the AI can see the position), and a Hit output means there is at least one wall between them (so the AI cannot see the position).

3 Likes

AHH! This is crazy!

I know right!

2 Likes

Just finished version 3 of my basic top-down pathfinding; here are some of its features:

-super fast performance (you could actually add this to a game and have it still be playable)
-multiple targets and followers
-moveable / destroyable obstacles, targets, and followers
-dynamic map boundaries (you can go out of bounds and the pathfinding still works)
-easier to edit code (though it’s still kind of complicated, so let me know if you have questions)

There is, however, one big downside to this version, which is that it uses the Message behavior instead of the Global behavior. This means you cannot just copy and paste the code like before— you have to make sure you set all of the messages up properly. I’m sorry it works that way; Messages are just so much faster than Globals performance-wise.

Also I am working on making this Any-Angle, but it’s ended up being more complicated than I initially thought, so it may take a while to actually complete it. Same goes for the platformer / sidescrolling version of this; it’s going to be a lot more complicated to implement (thanks to gravity).

9 Likes