Andy Connacher - Architecture and 3D modelling portfolio
Andy Connacher
Portfolio

Real-time Environment Artist with a background in Architecture

︎ About
︎ Blog
︎ Contact

Andy Connacher
Portfolio





Making my first game in Unreal Engine: Part 2 - AI
10th March 2022

This blog post is part of a series of blog posts about Bard Game!

At this point, the test map in Bard Game was populated by:
  • a playable character (the titular Bard)
  • some static meshes (the houses)

This was fine as a starting point but, as with most games, I felt there should be more movement and dynamism in the world aside from just the player.

This would require creating another character and giving them some form of AI.



Introducing: The Peasant

To implement this, I decided to create a “Peasant” character.

The Peasant would be a glum-looking fellow with typical peasant garb and perhaps even a dirty shirt. The Peasant would simply wander around aimlessly with a moody gait and, for now, not really do much at all.

I used the Bard as a base to begin modelling the Peasant, replacing the hat for a coif, adding a peasant shawl and giving them their own texture map - what a lucky little peasant!


The Peasant!



The Peasant - in game

As usual, Chad was busy coding and implementing core gameplay mechanics so I took it upon myself to try and apply what little blueprint knowledge I had to code some simple AI roaming.

It’s not much but I was pretty happy with the result!


Peasants! See how they wander aimlessly?



A quick look at the code

I wont go into too much detail, but the key parts are:
  • Every tick (or frame), the game checks if I have set the Peasant’s CanMove variable to true
  • If CanMove = true then, after a random amount of time (between 1-5 seconds), the Peasant will randomly choose a location within a radius around itself and move to it. If CanMove = false, nothing will happen
  • While the Peasant is moving, it sets IsMoving? = true and when it’s reached its location, IsMoving? = false - this is to help tell the animation when to run the idle animation or the walking animation.


Peasant random roam AI using UE4’s blueprints



I exported the Peasant and sent it to Chad and for him it was simply a case of dragging the folder into the game.

And that’s pretty much it!

Thanks for taking the time to read this! Take it easy,

Andy


If you require 3D modelling services or you if you just want to talk about 3D modelling, feel free to get in touch with me here or on LinkedIn!


Andy Connacher - © 2022