Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Two AI units, Fighting each other

Discussion in 'Game Design' started by jericesteron, Mar 27, 2022.

  1. jericesteron

    jericesteron

    Joined:
    Feb 4, 2022
    Posts:
    1
    My game is a simple 2D plane with 2D units, an intro on the mechanics, There are two groups of units one will be called Attackers that have hero-like stats that is limited to 4 units only per game/map. the other one the defenders which will be like mob units not limited to any number of units can be 10 to 15 units per game/map, Imagine a kingdom rush tower defense style of gameplay without the towers for the attacking units to the defending units, in this case, the player can only influence the game by healing or activating the skills of the attackers, while the attackers move and behave as an AI on a Tower defense, My first problem is I am having trouble on how would I design the behavior of the attackers and behavior of the defenders in relation to the attackers. so my question is what are the best practices for designing AI behaviors with all of the given specifications.

    for example, the 4 units of the attackers first met 3 units of defenders for the first battle in the game/map, My first thought is all units will only attack 1 to 1 if all are occupied and there is an extra it will attack the nearby units thus creating a 2 to 1. My question on this is what are the best coding practices on how to execute this scenario in a script.

    Btw, it would really great to have a more detailed answer and think of this as me learning good coding or designing practices.

    Lastly, this is my first question in this forum I am not sure if this is the best place to ask this question.
     
  2. angrypenguin

    angrypenguin

    Joined:
    Dec 29, 2011
    Posts:
    15,601
    If your question is about how to code it then it should go in the Scripting section.

    This is a really broad question, though. When you say "best practices" what do you mean? Are you looking for a pattern to use to set up your classes? Target selection algorithms? Do you want someone to write up a software design for you?

    It'd help if we knew what you'd already tried so we could point you in a direction or make suggestions from there. There are many "right" answers to this which will work, so my main suggestion, as broad as the question itself, is to try something and see what does and doesn't work well with it. Many peoples' early attempts at coding up a game are less about being unable to code something and more about not wanting to start until they've got a perfect solution... which often doesn't exist.
     
    Martin_H likes this.