Day 51: Today, I had trouble to wake up. Maybe it’s related to fact that I spent the night before playing Skyrim… Other than that, it was a pretty standard day. I took taks to do. Did them, did some other tasks. Realized I could actually improve stuff. Did those improvements and poof end of the day. But you want details I suppose. Well okay, but it really because it’s you. Today I:
Implemented seven enemies. At first I aimed for four. Then I thought six. And then at the end I had time for one more. So seven new enemies:
“Turret like”: stays fixed shoots three bullet in cone toward the player. Then at a longer interval it shoots two fast bullets toward the player. I realized while doing this enemy, that I don’t have any dedicated script to make the enemy look at the player. It’s directly in the TargetMovement. So I added a target movement to this enemy. But then I thought that a lot of calculation was done for nothing. So I added a check at start that start the movement routine only if speed > 0.
“Popcorn”: really weak just goes left/right and shoots the player from time to time. Nothing particular happened during the creation of this enemy.
“Melee”: goes toward the player at medium/high speed. Doesn’t shoot. I had to tweak the TargetMovement variables to have a correct collision avoidance. I shouldn’t have to tweak it. It feels like stitching decomposing zombie limbs. It kinda works but it’s not really a permanent solution.
“Square”: has a “square” waypoint patrol. Shoots four bullet in cross (✚). Funny thing, the enemy is named “Square” but the sprite is a circle. (you dare to call that “funny”? Man you really have low joke standards).
“Base”: doesn’t move. Shoots a circle of bullets. Called “Base” as in rebel base. No llama were hurt during the creation of this enemy (at least not by me).
“Spiral base”: Like a base but shoots in spiral. This means there’s a delay between each bullet. Also it shoots continuously.
“Turret”: Just a turret in the wall. It shoots forward. I used the new distance switch to activate it before you enter a room. Right now it’s destructible. But I’m not sure I’ll keep this.
Did some cleanup. Stuff like deleting old enemies prefab or minor script fixes.
Separated the enemy weapons from the player weapons. Because I was alway putting the same thing in the enemy weapons. I just put an absurd amount of max fire time (over 9000). And it used the same code than the player who has stuff like cool downs. So I separated it into two distinct scripts.
Modified the way enemy behaviours are switched. Before I used the “enabled” variable that allowed me to disable the Update method. But that didn’t work well. There was too many side effects. Like when a script needed a player reference. It would then disable itself, wait for the event and enable itself. But with a switch active, it woud fucked up everything. I had little control and I didn’t like it. So instead I implemented a simple Interface that forces classes that want to be switched to have a SwitchState method. Within that method I can do whatever I want. In particular I can have an internal bool that says if the script can be activated at all. It works well but the Unity inspector can’t serialize my interface type. So I have to still use a Behaviour variable and cast it to my interface. I should do a custom inspector but laziness took over. Plus, nothing like a big red error to catch my attention right?
0 comments