I need help with making an AI for a 2D enemy. I have no clue how to do it myself, so I’m just gonna throw out there what I want from the AI and hope you guys will be able to help. I’d want it to be a basic script for a boss how shots at a certain rate and take a certain about of hits before killed. Some pathfinding would also be nice, and random jumping could also work I guess.
The entirety of that all depends on how you want it to function within your game and how your game is set up.
All of that is going to take quite a bit of coding and can be done several different ways.
If you are using the built in 2D Physics engine then all you need to do for basic pathfinding is to compare your boss position to your player position and then apply a force towards the player. If the boss hits a wall (some position for multiple frames) then apply an upward force to make him jump over it or some such. Create a Random Number Generator and randomly apply an upward force at certain intervals.
For taking a certain amount of hits just make a simple script that holds his HP that gets decreased every time it gets hit by the character.
All in all this isn’t a basic thing. You shouldn’t be asking for such general help. We aren’t here to make your game for you. You’re asking for some fairly basic stuff, but it takes a long time to code, and it is all dependent upon how you want it to function and how you are coding the rest of your game. If you go write some code and then come back asking for specific help then we can do that. But just saying, " I want this " isn’t going to get you much help on these forums.
Well, I have no clue what so ever on how to make an AI so, all I’ve managed to do so far is Player controlls, animations and loading new scenes. So I can’t really show you any code for the AI to get help on since on don’t even know how or where to start
Usually AI doesn’t have to be anything complicated.
For something like you are talking about all you really need to do is have a bit of code that says “If the player is near, find the direction of player, move in that direction”
http://docs.unity3d.com/Documentation/Manual/DirectionDistanceFromOneObjectToAnother.html
I suggest looking at that to find distance and direction of objects
For the shooting, create a simple function that shoots objects from the boss, and then have it run on a timer.
And if you really want some pathfinding then you can look into this
http://arongranberg.com/astar/
or learn to implement it yourself