Devblog Update #10: Performance Enhancements and Sneakyness

It’s Monday! Time for a Devblog! This sprint really wasn’t much to look at (hence no screenshots), but it makes it easier to look at!


As I mentioned at the end of last devblog, while implementing the flying enemy there were a few performance issues that cropped up which were a bit concerning. Tackling that was my main goal for this sprint, and it took a few days to narrow it down! At first I thought it was some poorly written code, like an big “FOR EACH” statement going off every tick or something. I combed through everything, and did find a few areas to optimize, which helped a tiny bit. It was getting to the point of thinking I was going to have to re-write all the enemy AI code in C++, which I really wasn’t looking forward to. I manually lowered the tick speed on each of the main components of the enemy, to help debug, with limited success. I even learned how to use Unreal’s Performance Profiling tools, which are really cool!

In the end, I managed to narrow down the issue to one of the big collision shapes the enemy uses to detect the player (or an enemy AI). After a lot more debugging, I realized (in a big face-palm moment) that the enemy’s detection shape was set to collide with EVERYTHING… So as it flies around it’s supposed to detect when a new object enters its range, and check if it’s an enemy or not. It was doing this with every rock, shrub, tree, bush, stick, etc. Once I changed it to only trigger overlap events with Pawns the performance went from about 13fps back up to a smooth 60fps 😀
Several days of debugging to figure out it was one little setting… Classic.

Enemy AI

Once the performance bugs were nailed down, the rest of the sprint was spent trying to get the enemy to be a bit smarter. Here’s a few of the new things it can do!
– The ranged flyer will circle the enemy and once behind them will dive towards the player shooting at them. Before they’d crash into the player but now they veer off to the side once they get close.

– I realized that some of the variables the flyer was referencing weren’t actually being passed on! So some functions like “match speed with target” were completely non-functional! That’s fixed, so the enemy actually flies at the right speed now 😛
– There is now a “suspicious mode” the enemy goes into before it is fully alerted to the player. While in this mode, the enemy steers somewhat towards the player, investigating a bit. This still needs to be polished and tested a lot more though!

Well, there you go! Slightly more dangerous/interesting enemies, and smooth enough gameplay to actually play. We’ll see what we get up to next sprint! See you then! – SDG