More switches!

During the past week, I extended my knowledge and experience with enum state switches. I managed to do two things that I had not done before with the state switch systems. The first being a pseudo AI fleeing mechanic, which required me to consider more about the switching of states rather than the states themselves, and a wave progression system that controls spawning of enemies.

 

Firstly, the pseudo AI system that I implemented is indeed the one I mentioned in a previous week. However, while it functioned well and I was proud of the behaviour, this intended function does still contain the failures that I mentioned. Being the case where the enemy will run past the player to run away from the player. I have had some ideas on how to solve this, but will not have time to implement them due to how close I am to shipping the project. But in the state that it is, the pseudo AI has had great effects on combat.

 

While I was creating this system, I of course ran into some issues. At first I was not setting destinations when the date changed, but instead I would set destinations in the update while in the state. This resulted in my enemy’s dancing back and forth trying to decide which destination to take. I hadn’t yet realised that I could set the destination when it switched to the flee state instead, using the update to check for when to change states rather than to state a behaviour.

 

For the second use of the state switch system was the wave controller. I needed to create a function that would wait until all enemies were dead before giving a rest period and spawning new enemies. To do this I used three states: spawning, killing, and waiting.

 

During the spawning state, the game will spawn an enemy after an assigned time until the required amount of enemies have been spawned, then move on to the killing state. During the killing state the game will wait until all enemies are dead, then move on to the waiting stage. During the waiting state, the game will wait for the assigned time then move back to the spawning state

 

I again had to use the switching of states to control behaviour, like setting spawn counts and wait period lengths. While this use is new to me, has opened up many possibilities and ways that enum state switches can be applied and it is exciting! Here is one person who has used enum state switches to both increase waves and difficulty, I would love to do this at some stage in the future.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s