Skip to content
/ skadai Public

Decision-making and movements for squad managment using Utility System

Notifications You must be signed in to change notification settings

Skadaii/skadai

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

51 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Skadaï: Decision-making and movements in AI - Unity/C#

ISART DIGITAL GP3, School Project: Benjamin MARIN, Noé MOUCHEL, Rémi GINER

CircleFormation

About The Project

Unity Gitlab

The goal of the project is to make an NPC AI that moves as a squad and can interact with the player, in a real-time action game.

Table of contents

  1. Features & usage
  2. How to launch
  3. Details
  4. Reference
  5. Versionning
  6. Autors

Features & usage

Features

  • Smart AIs
  • Utility system
  • Ally and enemy squad system
  • Character classes (Healer, Support...)

Controls

The controls are made for keyboard only:

  • WASD - Move
  • Mouse movements - Aim and move squad
  • Left click - Shoot
  • Right click - Call for support fire

How to launch

Launch the exe directly from the archive.

Details

Utility system

To integrate artificial intelligence in the project, we have to make a decisional model which is the utility system.

Action Set

The utility system is composed of a list of actions stored in a scriptable object.

ActionSet

Creation of an action list in the utility ai

An action is composed of methods and a consideration.

Consideration

Taking an action into account will be evaluated and will give a value between 0 and 1, this value is evaluated from an input and a curve. The input is a method that will return a value, for example, the distance of the player from an enemy. And we will plot a curve against this input that will determine the utility (between 0 and 1) that will be returned by the consideration evaluation.

Consideration

Exemple of consideration

The utility system will evaluate all the considerations of the actions in order to derive the best action to perform.

Methods

When an action is executed it will invoke all the methods of the action. The listed components are all the components attached to the Game Object where the utility system is and the listed methods are all the public methods of the component.

Methods

Creation of a method in an action

To facilitate the integration of the actions in the utility system we decided to make a custom inspector, for example thanks to this we can list the methods available in the components.

Squad system

Unit system

To make a Squad system compatible with different types of controllers ( direct player inputs and NavMesh calculations), we had to create a leader-squad system. When the leader decides to make a move, the rest of the squad must follow this order. The units will not try to reachg the leader directly, but the position where the leader wants to be. This allows us to easily do a patrol system and a unit tracking.

To make the leader send its orders each time it wants to move, we used inheritance and UnityEvents. The leader's orders are linked to its movements updates.

leader.GetComponent<Movement>().OnMoveChange.AddListener(UpdatePositions);

UnitLeader Movements of a Player directed squad and an AI directed squad

To create an AI team, we had to create a virtual leader (with no collision nor rendering) who cannot die.

VirtualLeader

Prefab of a Virtual Leader

Formation system

To make the units follow the leader's order, the leader must tell the squad (which is a separate GameObject) where it wants to go. Before the squad tells its units where to go, it calculates the correct position that follows its formation rule (which is a manually configured ScriptableObject) for each unit.

CircleFormation Modular circular formation of a squad

Squad controller

To achieve a proper Squad system, we had to create an entity that represents a Squad to manage its own units. The Squad Controller instantiates its units according to its initial formation and number of units. Then, it will be the bridge between the leader and the rest of the squad, through which the leader's orders will pass.

SquadController Enemy patrol squad instantiation

Gameplay integration

We used the utility system to make specific AI action as healing, coverig or even shooting. We just had to make a consideration function then method(s) function(s), here an example of the healer utility system.

HealerUtilitySystem

Healer utility system

The healer has two actions, shoot at target and heal, shoot at target consideration has lower maximum value, the healing consideration can return a higher value so the healer will in priority heal hurted teammates instead of figthing enemies.

HealerUtilitySystem

Healer target consideration

HealerUtilitySystem

Healer healing consideration

Our system is not limited to only help the player, AI can help each others, a healer can heal anyone but himself, and supports can cover everyone but not supports. The player stays in priority when the unit choose who to help. The targeting choice is managed in the file Assets/Scripts/Units/UnitSquad.cs.




In the support action, for support units, we use a double method, the shootAtTarget and the cover methods are called so support can cover and shoot at the same time.

HealerUtilitySystem
Support action


You can also find in Assets/Scripts/Agents/AIAgent.cs, the consideration and method for the shooting behaviour of the units and turrets.


References:

Versionning

Git Lab was used for the versioning during of the development of this project.

Authors

  • Noé MOUCHEL Github itch.io
  • Benjamin MARIN Github itch.io
  • Rémi GINER Github itch.io