I am trying to get pathfinding to work for a basic rpg/rts game. What I did was create a Layered Grid Graph for my terrain, because I’ll need another level soon. It is using the following parameters:
Merge Span Range: 0.5, Character height: 0.6, Max Climb: 0.4
WidthxHeigth: 200x200, Node size: 10, aspect: 1
When I generate the grid most of nodes seem ok. I got a couple of yellow segments, but they are probably ok too. My agents use the default RVOController, my obstacles(buildings) contain a RVOObstacle with the approriate parameters.
I am encountering the following problems consistently:
My agents just stop throwing the warning: Couldn’t find a close node to the start/end point.
My agents keep running into obstacles in the scene until they magically slide off of them.
I am encountering more problems, but these two are the latest two.
“My agents just stop throwing the warning: Couldn’t find a close node to the start/end point.”
This happens when there are no close valid nodes to the character. Check the distance to the closest valid node. Also consider incrementing A* Inspector -> Settings -> Max Nearest Node Distance (or a similarly named setting).
Local avoidance is mostly for agent-agent avoidance, wall avoidance should primarily be done via pathfinding, this type of local avoidance is not very well suited for static obstacles avoidance, it is there more to make sure agents don’t walk through walls. If the static obstacle avoidance is complemented with pathfinding, it usually works very well.
If this does not help you, could you post a screenshot?
Just to make sure. How does setup and workflow look like for a game like this?
Units: RVOControllers for movement and avoidance
Buildings: RVOObstacle and graph update on placement
Props: see buildings
Is that correct?
Edit: Sometimes I get the error: object reference not set to an instance… in RVOController.OnEnable in line 89 (rvoAgent = simulator…) although there is a simulator in the scene.
"Edit: Sometimes I get the error: object reference not set to an instance... in RVOController.OnEnable in line 89 (rvoAgent = simulator..) although there is a simulator in the scene."
Try moving the simulator to the gameobject with the main Astar pathfinding script~
Just to make sure. How does setup and workflow look like for a game like this?
Well… It depends~ Mine is set up like so:
All Buildings↓
Building↓
Settings // My RVOObstacle, colliders, and such
Rendered // How it look, meshes and stuff
Props-> // Pretty much the same as buildings
All Units↓
Unit↓
… Other shit(Like stats, waypoints, pathfinding paths, and stuff that does not need to be on the agent)
Agent↓
Rendered
Settings
Ok, I think I am making some progress. For some reason the graph won’t update when I add a building’s collider to the unwalkable area. Not sure why, because I got a go with the script attached and calling it via AstarPath.active.UpdateGraphs(go.renderer.bounds);
Edit: For some reason layered graph doesn’t work that well with collision detection. I am using the exact same input with a normal grid graph and it works.