3D FPS Enemy AI

Hi, I was wondering how I would program a 3D FPS enemy AI system, so the enemy soldiers could chase you, hide behind walls, shoot with guns, and patrol. Thanks!

That’s a lot, you are asking. While I am not going to lay out all mechanics for you here, since it would be hillarious without knowing where you’re at currently, I can give you some starting inspirations/questions:

First movement: You can use forces, pathfinding, or calculate positional changes yourself. Each creates movement-patterns that can feel tremendously different. Pick one and experiment.

Then enemy states: create a state variable and experiment with different conditions and actions. When does the enemy patrol? When do they hide? When to shoot? When to chase? There is many different ways of handling states. (You can read on state machines, behaviour trees, AI planning, pushdown automata, etc. online. If you run into issues you can ask here.)

Basic concept to start with could be: Start with a patrol state as default. When the player comes into sight range, you start shoting. If the player leaves sight range you chase him for as long as he is still in sight. If the enemy loses sight they go back to their patrol spot and patrol.

Don’t overcomplicate it at first. Just start with one single enemy with two states: patrol and shoot. You can add on this later.

Thanks! I will keep your tips in mind!