I’m creating simple 2D game in which you play football. It’s very similar to other games like this one that you can fin on the internet(for example this), I just think that it’s a good way of learning unity. Each team consists of 3 players, one of them is controlled by the person who is playing the game.
Now, I have finished the steering and basic game mechanics I need to create the AI for opposing team.
I don’t want to make opposing players just run to the ball and kick it, i would like something more effective. Are there any common ways of solving problems like this? I want the bots to be as effective as possible, they don’t have to imitate real football players behavior. Do you know how can I do it? Or maybe its already done somewhere and I could use it?
I am afraid that nobody is able to tell you all principles of AI in a few messages. It is a topic for large discussions, I would even say lectures. There are a lot of books, videos and articles about AI. You should look at them. All AIs are different, because the coders expect them to be differently. They have different duties and behaviours. There is no solution that would work for every kind of game. So, you have to emphasise things that are important in the game, watch/read articles, books, videos about AI, and take from there necessary skills and ideas.
I believe there are a lot of AI assets in Asset Store, but, unfortunately, without knowing how it works, the assets are useless. They won’t work exactly as you want from the box.
Yeah, it’s football game, you need to score a goal by hitting the ball. It looks very similar to the screenshot i liked. I don’t want to learn all the rules about making AI, I just ask if there are any common ways of doing this specific type of AI.
No, there is no “common way” of doing something like that without self-brain-storming. Actually, the most “common way” of doing the simplest actions is just RUN and KICK. To make more advanced AIs requires more knowledge and investigation.
well… there are things like “Steering Behaviours” (https://gamedevelopment.tutsplus.com/series/understanding-steering-behaviors--gamedev-12732
) and other low level AI movement approaches… you could add a layer over those which chooses when to intercept/chase/whatever, that bit would certainly be a tailored AI to your requirements.
At the very least looking into things like that would explain how to combine movement priorities (I want to pursue and also block a pass => single movement vector etc.)
edit: there’s also a more specific tut on there (different sport and different platform, but the approaches are the same) https://gamedevelopment.tutsplus.com/series/create-ai-for-a-hockey-game-using-steering-behaviors--cms-604
Generally, writing an AI is describing how an entity would behave in different situations in a way to render the behavior plausible in the eye of the player. As @romatallinn already said, there is no common way of doing it. So it’s up to you.
If you never wrote an AI before, you shouldn’t start with writing AIs that play football. This game is quiet complex (from a programming perspective). Each player would behave differently according to its position/role on the field, and each of them have to consider the whole team positions and states as well as the opponents… there is a lot of decision making process to program in there…
.
Find the ball. Am I the closest teammate to the ball? If true: Go for the ball. If false: Head back to my zone.
That should get you started.