Devlog: Designing interaction between player and autonomous AI - Ivan Shyika
Hi! I am Ivan "John Ivess" Shyika, the Team Leader, Project Manager, and one of the developers. In this post, I wanted to highlight one of the technical design problems I worked on last week.
Problem
One of the problems I tackled this week was rapidly designing the fundamental setup of our essential game systems. One of such systems was the interaction and the relationship between the player input, autonomous hero AI (self-governing logic of the player unit), and the player unit as a character.
The problem was, which element is responsible for which functions? How exactly can a self-governing AI be combined with player instructions so that both systems are equally valuable?
How should it work?
First, I identified the target behavior:
- Hero squad movement is controlled entirely by the player. The squad holds their position and does not pursue enemies or retreat unless directed so explicitly.
- Heroes can be entirely autonomous in combat: by default, they target and continue to attack the first enemy they detect within their attack reach. If the target becomes invalid (dies or becomes out of reach), the hero will lock in on the "new" closest enemy.
- The player can command the squad to attack a specific target, which will override their current target(s). Every hero who can reach that enemy will lock in on that enemy; otherwise the hero will continues to attack their old target.
How can I make it work that way?
Now, how can it be implemented in code?
- Hero AI commands the Hero entity to move to their position within the squad center object.
- If player orders the squad to move and the location is valid, the squad center teleports to there. Following the bullet point above, AI triggers the Hero to move.
- Both the Hero entity and Hero AI remember the target enemy. The entity uses this knowledge to aim at the target, while the AI evaluates the current target against potential targets.
- When the player targets an enemy, the target is updated in Hero AI. If the Hero can reach the target with their attack, the Hero AI updates the target in the Hero entity so that the latter can direct their attacks at a new enemy. Otherwise, the AI assumes the old target.
In other words, heroes fight autonomously but don't move independently, and the player directs them and can suggest a new enemy target. Simple yet effective!
It now was Keegen Love's turn to implement the design in code. :)
Get Return to Divinity
Return to Divinity
Strategic combat, tactical formations, and perilous dungeon runs—can you survive the depths?
More posts
- Devlog: Overhauling Squad Movement and Formations - Keegen Love9 hours ago
- Devlog: Hero Classes and Special Abilities - Ivan Shyika18 hours ago
- DevLog: Implementing Death (Animations) - Violet Weathersby19 hours ago
- Devlog: Preserving squad data across levels - Ivan Shyika6 days ago
- DevLog: Squad Selection Crashes - Violet Weathersby6 days ago
- Devlog: Fixing Squad AI Freezing in Combat: A Deep Dive into Task Instancing and...6 days ago
- DevLog: Camera Issues - Adam Denomme6 days ago
- DevLog: Creating the Player HUD - Violet Weathersby13 days ago
- DevLog: Fixing Invalid Click Locations in Pathfinding - Keegen Love13 days ago
Leave a comment
Log in with itch.io to leave a comment.