Artificial Intelligence for Games in Unity

Asked

Viewed 367 times

5

I’m creating a game at Unity, and I’m looking to do some bosses, but for that I need to study artificial intelligence, and I have no idea where to start, I looked for books but they are very scarce, and the ones I found or not are in C#(only language I know besides Kotlin) or else(most common) has no relation to Games, where I can get sources of Study? The Boss Style I want to design is in the Hollow Knight Game Style, if you can take a look at the first Bones, the "False Knight" I would really appreciate it! Recommend me places to study it! I have a great thirst for knowledge and learn fast, I just need the right source or sources.

  • 2

    Are you sure you need an artificial intelligence, not a 'simple' intelligence, with predefined and unchanged standards, like 98% of the world’s games?

  • recommend seeing the following websites before making that decision: https://answall.com/questions/86869/o-que%C3%A9-Intelig%C3%aancia-artificial? Rq=1, https://pt.wikipedia.org/wiki/Inteligência_artificial, https://www.tecmundo.com.br/intel/intelid/o-que-e-inteligencia-artificial-.htm, https://canaltech.com.br/inteligencia-artificial/entenda-importancia-da-inteligencia-artificial-100442/

2 answers

6

The head "False Knight" at Hollow Night does not use advanced AI as machine Learning or deep Learning, which are Ias of learning. You can decorate the patterns of bosses with time in Hollow Night, such as when he will attack in this way or jump or hit the club on both sides of the floor, and his brain memorizes these patterns over time. So False Knight uses a simple AI called : Finite state machine. It’s a good start to start studying.

What does this mean? That it has its preset attacks for example:

  1. Jump attack and clap on the character’s course.
  2. Simple clava attack.
  3. Clava attack with chao power.
  4. Clava attack in the center of both sides.

Basically the finite state machine will tell the conditions under which it will perform each attack. Example of conditions:

  1. Player is near.
  2. Playes is far away.
  3. Player is on the air.

A C# representation could be:

public enum BossStateIA
{
     ExecutandoAcao,
     RequerAcao
}

public enum BossAcao
{
     Nenhuma,
     AtaqueSimples,
     AtaquePulo,
     AtaqueEspecial
}

public class Boss
{
     private BossStateIA State;
     private Acao AcaoAtual;

     private Acao IA()
     {
         Acao acao;

         //Define a próxima ação a ser feita em uma máquina de estados
         //finitas, simplesmente use ifs, and e or. Se o personagem 
         //está perto, longe, pouca vida ets.

         return acao;
     }

     public void Update()
     {
         if (State == BossStateIA.RequerAcao)
         {
             AcaoAtual = IA();
             State = BossStateIA.ExecutandoAcao;
         }

         //Executa o código de acordo com a ação atual.
         //No final da ação defina a variável State para RequerAcao.
     }
}

0

Artificial intelligence for games is a series of standards running for certain actions, not worth using machine-Learning or deep-Learning, I would do something like this

bool acao = false;

void Update(){
  if(!acao && Vector3.Distance(transform.position, player.position) < 5){
    Atacar();
    acao = true;
  }else if(!acao && Vector3.Distance(transform.position, player.position) > 50){
    AvançarNoPlayer();
    acao = true;
  }
}

void Atacar(){
 // Atacar
 acao = false; 
}

void AvançarNoPlayer(){
 // AvançarNoPlayer
 acao = false; 
}

and so on

Browser other questions tagged

You are not signed in. Login or sign up in order to post.