Skip to main content

On-Rails Shooter Project - Week #4 - Adding Enemy AI


With control of the player character's location and rotation achieved it's time to work on something else that will grab the players attention and challenge them, the enemy AI.

I have had some poor experience with programming AI during my Trash Collector project so in this project I am going to attempt multiple different ways of programming enemies then choose one that bets fits my use case afterwards.


1st Enemy - Simple AI

The quickest and easiest solution is to do the same as when moving the player character and simply grab the enemies current location then linearly move between that and a desired new location, luckily for me this is a pre-programmed function of Unreal Engine in the "AI MoveTo" node which will linearly transition between the starting location of any Pawn class plugged into the node and then the location data plugged into the "Destination" pin. I started by selecting the player characters location as the destination so even if the player was not currently standing at Target Point #2's location this "Simple AI" enemy will still chase the player.


2nd Enemy - Spline path

Another method is to use a spline to determine the path that an enemy would take. This is a much better fit for my use case as this method is adjustable, the spline can be extended and moved around the level multiple times and the enemy will still follow its trail. To do this however the enemy character blueprint needs to know which of many splines contained within this level it should be following so for that I created a instance editable variable that the developer working on the level can use to attach all the different instances of enemies there are in the level to the appropriate splines. For actually moving the enemy actor along the path of the spline I will set the location of the enemy at the location found at the "Distance" along the spline but the selected distance input will be a float that changes over time, this changing float is going to vary depending on the current point that the timeline is at. The distance is going to go between 0 and the max length of the spline using the timeline out float as an alpha which is how this variable is changing over time.


3rd Enemy - Behaviour Tree

Whenever I attempt to search up programming an enemy character the results I get back are always referring to a behaviour tree (or a behaviour tree like structure) which is a class of code that can take note of a series of tasks and then use an algorithm to decide between the outcomes and make a choice of what actions to perform based upon some parameters attached to those tasks. Inside Unreal Engine a Behaviour Tree is accompanied by a Blackboard which is where the series of possible tasks and information a Behaviour Tree needs is stored within the project. This is how most typical 3D games program their enemies as it allows for the AI to not only choose between chasing the player or patrolling a nav mesh, it also allows for the AI to back away from the player character if the player character is marked as being in a rage state or allow for the AI to decide it's shield is too low to continue on the offensive against the player.

While a behaviour tree algorithm is incredibly useful I do not feel it is required for this project or will add enough additional value to the player experience over choosing to use the 2nd Enemy method of attaching the actors to pre-planned spline paths.


Comments

Popular posts from this blog

Guest Lecture #1 - 21/09/2022 - Secret Mode

Guest - Joshua Garrity, Head Game Scout at Secret Mode Guest Bio Joshua started as a product Manager in the marketing department. Joshua was in charge of digital publishing for Fireshine. Attending public events like Gamescom not only allowed him to network his way into the position as Head Scout at Secret Mode but is also a method he uses to accomplish his job by seeing new indie projects in beta stages at these events. Takeaway #1 – How to Pitch my projects Scouts and Studio CEOs will be travelling often and walking around both Hotels and event centers, so  you  need to be able to pitch your project anywhere at any time. This means your presentation needs to be smooth, quick, and confident, when talking with scouts, CEO, or other representatives you need to answer their questions (without checking notes) and speak honestly about what your team has done and what it will cost for your studio team to do more. Takeaway #2 – What Do Game Scouts Get Up to Game Scouts in their day-...

Guest Lecture #4 - 19/10/2022 - 10:10 Games

  1st Guest Bio - Bart Kosciolek, Junior Animator @ 10:10 Games Jfjdiejdjd 2nd Guest Bio - Reece Hewitson, Junior Games Developer @ 10:10 Games skdjalskjdlkasjd Takeaway #1 - Determination As an applicant trying to get into the industry I will be rejected many times due not being the correct fit for studios I am applying for, be it not enough experience or not the correct style of work for how the studio does things. I need to not let this deter me.  Takeaway #2 - Networking The video games industry is still very young (in business terms/years) and still very small (in one sense), while a single title is a product of many peoples work all put together those people often split after projects have been finished and they will end up working on other projects at other studios and this results in "everyone knows everybody" where you can say a name in conversation with a new co-worker and they'll reply with "oh yeah I know (name) I've worked with them on this project. ...

Guest Lecture #2 - 05/10/2022 - Rebellion Games

  Guest - Peter Dimitrov, Environment Artist @ Rebellion Games Guest Bio Peter enlightened us and told us his day-to-day while he worked on the 1st DLC project for Sniper Elite 5, as a environment artist Peter worked with another level designer to develop and refine the flooded map level that the 2 of them had been assigned to.  Takeaway #1 - Working with limitations      Both Peter and his co-worker had to stick to a schedule where sections of the map needed to be                   done to a specific deadline, the white box version needed to be done within a certain time limit,                   changes could not be made once the art pass had started, the map needed to include certain features like      ditches and a spot for a supply train to run through. The map itself went under many changes before         ...