Hi! I’ve gotten to the point in my game where I have to start worrying about AI creation… The thing is, I’m not very familiar with AI. I barely dealt with AI back when I started working with games, and it was very simple and trivial. The game that I’m currently working on is a 2D sidescrolling platformer, very similar to “Samurai Gunn”. The AI that I’d like to come up with has to “know” how to do the following things:
If the player is within range, begin following him. If he’s within a certain range, either sprint or walk
Be able to jump over obstacles (probably a line trace and then checks for a tag)
Be able to figure out how to walljump to the player’s location
When the player is within a certain range, attack him
Sometimes jump randomly over the player (he can attack in air, makes the AI feel better)
Sometimes throw a weapon
Sometimes block the player’s attacks
The player can already do all of those, I just don’t know how to get the AI to do all these. I’m really confused were this is concerned, I need someone to help steer me in the right direction please XD (I’ll buy you a beer :'3). From that list, I can somewhat grasp my head around how I would do most of these (except for 3, I have no idea how to do that one O.o), but I don’t really know what I would use. Would I use behavior trees? AI controllers? How would I use these in a 2D game? Anything helps, really. How would you do any of these?
Getting the AI to jump as a part of path following is, unfortunately, an EXTREMELY complicated endeavor and there’s no easy solution, especially not for BP.
I have a system that somewhat works, but it requires a lot of setup and isn’t extremely elegant. I’ll post about it later tonight; essentially the idea is you use NavLinkProxy elements to connect all jumpable points, and then use trigger volumes to communicate necessary jump velocities when the enemy is inside said volume. Then, you have the AI run a parallel node whenever he’s in a MoveTo state that constantly checks if certain conditions are met (the player is above him, a line trace reveals a pit, etc) and if they are, it Launches him using the velocity which is fed to him by the overlap volume (I originally tried having the overlap volumes perform the launch logic but it makes for problems when the enemy could, for example, EITHER jump up or drop down when he hits a trigger, and he must do the latter to reach the player)
it is very difficult for you to get help when you ask questions that are so vague. For example it would probably take a couple days for me to create all the above. So it would be impossible for someone to try and explain it to you in writing.
What you should do is break down everything into a lot smaller and precise questions. That way we can help you with one thing at a time and then you can use that knowledge to stitch up everything together to better suit your needs.
For example a very quick and dirty way to know how close is the enemy related to your player is to either create a line trace or you could get world position for the player, get world position of the enemy, ABS them and then say if enemy is closer than 400px then do this. If it is more than 400px but less than 500px do that etc.