Quantcast
Channel: GameDev.net
Viewing all articles
Browse latest Browse all 16874

Tips for programming enemy behaviour more efficiently/clean?

$
0
0

Imagine e.g. a 2D-platformer boss fight with one central enemy but with multiple phases. How would you program that?

I usually do that with a switch-case in the looped method ("void Update()" in Unity) and add a variable “status” which keeps track of the current action the boss is doing (moving to specific point, idle animation, circling, attack1, etc.). After a certain action is done I then change the status so that it goes into another “case”.

However I often run into the problem that the code gets to confusing over time because of the too long switch-case and …


Viewing all articles
Browse latest Browse all 16874

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>