something i really want to implement in my top down shooter game is a pathfinding system where the enemies (which are ghosts) can have the option to walk through walls if the system can determine it as being faster. While in the walls the ghosts are slowed to a third of their normal speed, so there will be situations where walking through a wall is faster than going around it. but no pathfinding system that i know of has something like this, any ideas?
#How would i make a Pathfinding system for my enemy characters, that can walk through walls?
1 messages · Page 1 of 1 (latest)
Godot has the AStar (or if it is 2d, the AStar2D) class which can easily handle this kind of thing.
- Do regular pathfinding (as in A* or a NavigationServer's
map_get_path()) to get a path with pathfinding - Calculate the length of this path
- Get the distance from the actor to the target in a straight line
- Shoot a recursive raycast (or maybe shape cast might be better) until you hit your target, counting the number (and thickness) of the walls you encounter
- Pad out the distance from 2 into a padded distance, accounting for the walls slowing them down
- Compare the two values. Use the smallest solution.
This is late but I need to ask wtf is a shape cast? I've found documentation for it but can't find it in the godot editor, and the only other thing I've found is a shape cast node addon used in goost, a godot C++ addon. Is there something I'm missing
it's like a raycast, except you move an entire shape to make your tests with (so it has width/height/depth/etc)
Though it's only in Godot 4, it doesn't exist in Godot 3
You can use a raycast instead
Im using Godot 3.5 so that's why, a problem I've found with raycasts is how they cant seem to detect a Tilemap being collided with, what's a good way to use a raycast to detect collisions with Tilemap walls?
is it actually possible to detect tilemap walls with raycast in the way i want to? im honestly out of options, ive tried anything i can think of or find online and i dont know what else i could do
ok ive gotten pretty close, the problem is that it doesn't seem to be able to detect multiple walls being in the way. it can only detect the first it collides with. heres what the code looks like right now
i also have something at the bottom of the script which resets num of walls btw