Devblog 3
A Cozy Monday Evening#
Hey everyone,
Today I worked on NPC movement. At the moment, the logic is still relatively simple: you create PatrolNodes, and the NPC moves from node to node, waits there for a defined amount of time, and then proceeds to the next one.
For each node, you can define:
- Waiting time
- Idle animation
This works quite well in principle, but it’s obviously not sufficient for an open-world RPG with a dynamic game world.
New System Concept#
I’ve therefore designed an expanded system consisting of three levels:
- PatrolNodeGroups
- PatrolAreas
- PatrolNodes
PatrolNodeGroups#
Within a PatrolNodeGroup, you can define multiple PatrolAreas. Each PatrolArea, in turn, contains the specific PatrolNodes for a particular region.
Example hierarchy:
- PatrolNodeGroup_1
- Area_NPC_HOME
- PatrolNode_Cook
- PatrolNode_WatchTV
- PatrolNode_DoRandomStuff
- Area_NPC_CITY
- PatrolNode_StayAtStreet
- PatrolNode_WorkAtSomething
- etc.
- Area_NPC_HOME
- PatrolNodeGroup_2
- Area_NPC_HOME
- PatrolNode_Cook
- PatrolNode_WatchTV
- PatrolNode_DoRandomStuff
- Area_NPC_BEACH
- PatrolNode_SitOnBench
- PatrolNode_BuildASandCastle
- etc.
- Area_NPC_HOME
PatrolBehaviour#
A PatrolBehaviour can be assigned to a PatrolNodeGroup.
Within the PatrolBehaviour, you define:
- In which months the group is active
- On which weekdays it is active
This allows for scenarios such as:
- From Monday to Friday, the NPC goes to work daily, works there, and returns home in the evening.
- On weekends, the NPC goes to the beach and relaxes.
Additionally, within a PatrolArea, you can define from which time onward switching to the next area is allowed.
Example:
The NPC stays in their apartment until 8:00 AM and then goes to work.
Pathfinding#
Today I also implemented a pathfinding system. The core logic is in place, but it has not yet been integrated into the NPC class.
The important point: pathfinding should not run permanently. It should be used selectively in order to reduce performance costs—especially when dealing with many NPCs.
Planned use cases:
- When switching PatrolAreas
- If an NPC gets stuck (e.g., due to collision with another NPC)
- Potentially for in-game cutscenes (future use case)
The reasoning is straightforward: continuous pathfinding across many NPCs can consume significant CPU resources.
Of course, it remains to be seen how this performs in practice. In the worst case, pathfinding might need to run continuously rather than only in defined edge cases. Playtesting will ultimately determine that.
I hope this gave you a small insight into my current development progress.
Best regards,
Nflaus