Context: I’m making a top-down game similar to Baldi’s basics, and I’m trying to make a chaser path-find its way to the player while avoiding tiles with hitboxes on. I have 2 tile maps. 1 has the floor, and it is not flagged as a pathfinding obstacle because the characters are supposed to walk on it. The other tile map has the walls, and it is flagged as a pathfinding obstacle. Problem: The walls tile map is including the empty spaces in the outline as obstacles, so the path finder can’t even walk in the empty spaces.
This is what the walls tile map looks like:
The white tiles are the walls. Summarized question: How do I make it so that my pathfinder can path-find to my player, while avoiding tiles with hitboxes (the white walls) but still walking through the empty spaces in the tile map?
If you’re using the builtin tilemap object then you need to use the nav mesh pathfinder and it’s obstacle behavior. The offical pathfinder uses the size of the tilemap for the obstacle and ignores the hitboxes. The Nav Mesh behavior uses the hitboxes.
Also be sure to include community extensions in your search.
Update, hmm, the community option is not available when adding a behavior to an object. But it is an option when adding a new extension in the extension list.
I found what the problem was with finding the nav mesh behavior. I didn’t have “show community behaviors” on. I found the behavior, and I gave it to my pathfinder along with TopDownMovement and regular Pathfinding. I gave my walls tile map NavMeshPathfindingObstacleBehavior.
I only have 1 event for it:
Condition: Scene exists Action:(NavMesh) Move Chaser to Player.X();Player.Y()
Problem: The chaser is avoiding the walls, but it’s not pathfinding to the player, it just stops when there’s a wall in the way. It also stops when the player passes through the empty space between the walls. I’m not sure how to explain the exact problem I’m having, and I can’t upload screen recordings, so here’s a picture of the room:
When the player exits the blue room, the chaser just stops chasing it even if there’s no wall in the way.
Do I need to add another event or behavior to get the chaser to actually path- find to the player?
Make sure the walls are the only tiles that have a hitbox. If you’re moving with nav mesh, then you won’t need any other behaviors on the object.
The destination needs to be reachable. It helps if the origin for the chaser is in the center and the destination is also in the center of the player. You can use player.CenterX and Y if the players origin isn’t in the center. If the center point isn’t used it can cause issues when objects are near walls.
Make sure the chaser is smaller than the door opening.
I think I know what the problem is. From what I’m seeing, the pathfinding is working perfectly when the player is inside the spawn screen window. When the player is outside the blue room but still in the spawn screen, the pathfinding works, and the chaser follows the player. But when the player leaves the spawn screen, the chaser stops moving until the player comes back in. Summarized question: How do I make the chaser continue to path-find towards the player even when the player has left the spawn window? (Just to clarify, the player has the SmoothCamera behavior.)