- Home /
simple AI - Beginner question
I am very new to programming, just thought I'd get that out to start with.
I am working on a Rugby League game at the moment and I have my player running around and acting the way he should, and I would like to animate his team mates to run around with him.
Now as I've not done any kind of AI programming before I'm not sure the first place I should start.
I reckon I need to have states set up (somehow), like Offence or Defence. So then I can set some rules for them to try to follow depending on the state they are in. eg if they are in Offence to stay behind the character with the ball, and to try to spread out evenly across the field
How should I go about setting up these states? I think if I get started on the right foot I should be about to work out the rest (or maybe not lol)
Would you have each state a different procedure? Would I handle states with triggers? would I have all the code for each state in a different script or should I have them all in one, just different procedures?
Am I even aiming in the right direction? should I not be worrying about states and just deal with behaviours?
Any help you could give me on this would be super.
Thanks guys
P.S The AI would be kind of similar to what you see in this old game ARL96
Answer by Posly · Feb 02, 2012 at 11:03 PM
If your new to programming this is going to be hard, AI isn't simple. Anyway's I would just have a lot of booleans and if they set the boolean true then they do something. That's how I do AI's.
Answer by TheCraiggers · Feb 03, 2012 at 01:21 AM
In the game I made, I used different scripts for each AI difficulty, but inherited the common stuff from a generic AI script. This allowed me to keep all the functions the same name, etc, although I could have probably done it just as easily with one mega script and a public variable or two. The way Unity is set up where you usually have to know the name of the script in order to interface with it removes some of the positives of inheriting code in my opinion. Still, this worked well in my case.
Which approach you take will likely boil down to how you want to interact with the AI, and how they will interact with each other.
Your answer
![](https://koobas.hobune.stream/wayback/20220613063700im_/https://answers.unity.com/themes/thub/images/avi.jpg)