In Revive & Prosper you will play with a few characters (my idea is that it would be limited to 20). You are not going to control them directly, but you will instead create for them jobs. Each character will have a defined priority for each type of job and once he gets idle he will look, based on the priority for available jobs, and if he finds one he will do it. It’s a similar system like RimWorld or its ancestor Going Medieval .
To do that characters need to be able to walk in the world and see all available jobs. My development approach is to create a map of all fields interconnected with each other where I can easily find all available locations with the job and I can find path between the character’s current position and his destination. Here is a short video showing what I did:
If you are interested in more details here they are.
The navigation (navmesh) is calculated on all fields. It’s a list of (for now) four other areas where characters can travel from this area. It allows travel on oblique areas up/down. Those are now defined by terrain, but it’s ready also for the stairs that characters will be able to build, etc. I did a simple representation of the navmesh in the world so I can see each field where it’s connected.
The navigation map looks like this:
You can see that the objects such as trees are accessible, but block walking through so player can get to those on the side but not those in the middle. This is just for debug and I don’t think that this is how trees will behave in the game. You can also see that there are walls in the game so the player can’t get through them, unless they are doors. I’m quite happy how it works, except not being able to walk on oblique areas horizontally. I’ll need to implement that.
When something changes in the world it would update the navmesh and I was trying to implement some optimal algorithm so each change doesn’t recalculate whole navmesh. And of course it stopped working in the video :).
Now if I want to find the path there are two steps to execute.
First I calculate the distance of each accessible field on the navmesh for the selected character. It’s very simple and very fast as I do have a whole net of connected fields. I created another visual presentation for that. You can see arrows only in the direction to the area with the higher distance. And you can see some areas are not accessible.
If I need to find only a path from A to B a simple optimization can be done to stop once a destination point is reached. But in my game the characters will usually look for an available job and walk to it, so in this way I can check each job’s location if the navigation found a path, and find the best one for the character.
Once this is done you need to find the path, which is very simple: You just start from the destination, check if it has distance set for the character. If yes, simply look for any connected field with a lower distance until you have to get to the start.
But as you can see this is a grid system and the character walks only in 90 degree radius. I don’t like it and I’d like to get the character to walk straight to the destination. I do have a few ideas that I’ll try. I already started so you can see the closest path is already through the middle of the area and not on the sides, which would be the typical result of such navigation.
Till next time..
One thought on “Walking of characters”
Comments are closed.