itch.io is community of indie game creators and players

Devlogs

Anti-Optimization

CrumBrawler
A downloadable game

The Problem:

The main issue that cost me a large amount of time this week had to do with the way visual studio and Unreal optimize things during compile. In the process of coding the enemy ai state I could not figure out why they never changed. I spent hours googling and trying different things but the enemies just stood there. I managed to get them to target the player but that was as far as I could get. The code was a simple one line statement setting a blackboard value.

At least 8 hours was spent trying to find why these functions would stop a breakpoint and then just get skipped over and not be called. Hours wasted and so much trial and error with no success.

The Solution:

Finally I found a stack overflow from over 8 years ago that said to put a statement that makes the engine do something. The example given was a debug statement. It gave a short explanation that the optimization done by visual studio had deemed these functions insignificant or not used. This lead to all my state changes to not be compiled and rendered them useless. I skeptically placed the debug in each of my states and hit the play button. Finally the enemy responded to all the state changes exactly how I expected they would. I really have no idea if the post that gave me the answer has the right reason this worked but the debug statements worked. After it compiled once I was able to comment the debugs out and it has been fine to this point. I would normally delete the comments while refactoring but these will stay in just in case visual studio decides to anti-optimize my code again.

Download CrumBrawler
Leave a comment