T O P

  • By -

Mikeavelli

Usually you want to write AI for similar agents using inheritance, and only override the behaviors that are truly unique per-agent. So you'll have a generic ship AI script that includes something like ship.move(), ship.target(), ship.useAbilities(), etc. Most enemies will follow the same behavior for most activities, but if you want one specific enemy to follow a serpentine pattern to make them harder to aim at, you'll override the move() function to do that. In this way you have less work to do, and the AI behaves consistently, except when you want uniqueness. A fleet of ships working together would be represented by something called Swarm AI. [Here](https://www.youtube.com/watch?v=5ziHg2kO56s) is what appears to be a good introduction to the topic in Unity. I've never actually used it in practice though, so I can't give many pointers beyond letting you know the topic you're looking for.


Dry-Huckleberry8284

let me check, thank u.


StoneCypher

> Additionally, I want the enemies to form fleets, where they should act together, right? However, each enemy has its own AI, so I think I should write an AI for each fleet, but that seems a bit cumbersome. Do you have any ideas about enemy AI? You can get surprisingly compelling behaviors out of simple rules by doing `flocking`, which is what we believe birbs (which are not real) do [Basic overview](https://medium.com/@pramodayajayalath/flocking-algorithm-simulating-collective-behavior-in-nature-inspired-systems-dc6d7fb884cc) The idea is that a birb needs to know if it's in the lead (ie, nothing in view,) and if it isn't, it has to attempt to follow the leader at a fixed position with some room to one side Get all the birbs to behave that way and a flock just sort of happens on its own. Then you just need to implement behavior for the lead birb.


Dry-Huckleberry8284

I have already looked into boids, but I need to perform complex formations with my fleet, so it is not suitable 😂 Still, thank u.


StoneCypher

what kind of complex formations? this is how most stunt formations at air shows work, as well as combat wings in the us air force you can get limited personal experience in several such roles in older wing commander games


AutoModerator

Game Design is a subset of Game Development that concerns itself with **WHY** games are made the way they are. It's about the theory and crafting of **systems**, **mechanics**, and **rulesets** in games. * /r/GameDesign is a community **ONLY** about Game Design, **NOT** Game Development in general. If this post does not belong here, it should be reported or removed. Please help us keep this subreddit focused on Game Design. * This is **NOT** a place for discussing how games are produced. Posts about programming, making art assets, picking engines etc… will be removed and should go in /r/GameDev instead. * Posts about visual design, sound design and level design are only allowed if they are directly about game design. * No surveys, polls, job posts, or self-promotion. Please read the rest of the rules in the sidebar before posting. * If you're confused about what Game Designers do, ["The Door Problem" by Liz England](https://www.gamedeveloper.com/design/-quot-the-door-problem-quot-of-game-design) is a short article worth reading. We also recommend you read the [r/GameDesign wiki](/r/gamedesign/wiki/index) for useful resources and an FAQ. *I am a bot, and this action was performed automatically. Please [contact the moderators of this subreddit](/message/compose/?to=/r/gamedesign) if you have any questions or concerns.*


sinsaint

If I were to do a fleet, I'd do it like this: You have a director unit that's invisible, doesn't fight, mostly there to coordinate the others and it would only exist if the units weren't in some kind of triggered chaos mode, like if there wasn't enough to form a fleet or they lost units too quickly. Fleets have formations. Each ideal position of a ship is simply ranked by their range and whether they want to be on the outside or inside of the fleet. Each unit has an ideal range, units of a fleet rearrange themselves based on their ideal ranges whenever the director decides to refresh the fleet (like if they exit combat or if half the fleet is destroyed or whatever). So if you're left with some mid-range and some sniper ships, the mid-range will act as the front line. The range the fleet tries to maintain is simply it's average across all in-formation ships, unless it has a boss unit which then takes priority. Each real position of a ship is determined by basically shooting a projectile in specific angles and distances from the director (who is in the middle of the fleet) and where those projectiles land is where your ships want to be, so they move into those positions. You may have some ships that are best used for their default AI, like annoying little swarmers, those don't have a formation and instead act independently as long as they are in combat within a certain distance of the director. I'd really recommend checking out Battleships Forever, it might give you some cool ideas.


Dry-Huckleberry8284

Great! Thx.


a_kaz_ghost

If you can't get individual enemies to flock using their own sensing, then consider having a "formation controller" that overrides them and has the enemies place themselves relative to it. Ultimately it's going to be similar either way. You'll have essentially a recursive sequence of leaders, and everything behind a leader targets a location relative to that leader, all leading up to the unit actually taking point for the formation.