Day 5–95% Complete with 2D Game Development
.
I am completely amazed on how far I have come in such a short time. Granted I put in a lot more than the 8 hours a day to get here, all the same I feel so great about the internship course material and my progress so far. I tend to get obsessive over things I enjoy and my addiction to this internship is on par with when I first discovered World of Warcrack in 2004.
I really felt like a lot of things clicked today. My mind is starting to think in the C# logic now whereas before I was force feeding my brain with concepts and solutions. I was able to complete the VFX, Post Processing, Game Audio and review the Deployment Sections. I did not spend too much time playing around with Post Processing, but most of what I see makes sense from my years of playing with my Graphic Settings on my PC and I plan to spend more time on this after I finish tweaking and enhancing the final product.
I did spend some extra time today off script from the course to address a few issues that were bothering me with the current build.
- When we started Spawning from the Asteroid Destruction, I noticed that if I shot multiple lasers it was causing multiple spawns. I removed the sprite after 0.25 after the explosionPrefab was called to create a smoother animation effect. I set a delay on the destruction of the Asteroid by 3.018 to match the animation runtime so it can run through completion but I also destroyed the Collider2D after 0.25seconds so I couldn’t keep shooting for 3.018 seconds. Prior to doing that I could fire repeatedly at the asteroid and trigger multiple explosion sounds and also multiple spawn of ships and powerups! LOL! Instead of destroying the Collider right away I left it for 0.25 seconds so I could get up to 2 shots in if I wanted to get a double spawn and hear a double explosion ( More fun!)
The next issue I tackled was creating player immunity for 2 seconds after the player gets damaged. That way when I run into a group of enemies I only take one hit instead of multiple hits. Prior to my fix If I hit 2 enemies at the same time I would lose 2 life. I set a higher spawn rate in my game and randomized it so sometimes there are clusters that form and it sucks to lose 2 lives at a time. I used a similar function to what we had done for the Laser Fire Rate.
Also, as you can see below I also added an explosion audio for when I get damaged to line up with when our engines get damaged. It felt strange to me get damaged, see an engine catch on fire but have no sound. I also successfully randomized which engine visual gets triggered by using an IF/ELSE statement embedded in a SWITCH statement (see below). Jonathan had mentioned randomizing this visual but never showed how to do it but I liked the idea so decided to take a stab at it. Not sure if its the most eloquent…but hey it works!
Another enhancement I did that wasn’t covered in the course…so far was the player ship exploding. I ran into an issue when first setting this up as the thrusters and my damaged engines where still showing as my ship was blowing up. I figured I had to destroy the children of the Player but did not know how so a quick google search taught me what I need and the below solution I Implemented solved the issue. I create a Gameobject name playerChildHolder on the Player and dragged the Player onto that field in the inspector since the Player is the parent. foreach (Transform child in playerChildHolder.transform) will call all the children in player and the Destroy(child.gameObject) will detroy them all. So now when the player blows up, the children animations like thrusters and engine damage will stop.
The last enhancement was on Enemy death I did not like how I could keep shooting the enemy and keep getting points even as he spent 2.5 seconds blowing u p so I set up an IF statement with a GetCurrentAnimatorStateInfo to check if the enemy was in the “enemy_Destroyed_anim” if it was then nothing happens and no points get scored if it wasn’t then 10 points get scored. (See Below) I also didn’t like that I could get damaged by going through the enemy after he exploded. So I destroyed the Enemy collider after 0.5 seconds. I felt like that was balanced. If I shoot and go through the first 0.5 seconds of the explosion I would get damaged but after 0.5 I can pass freely through, it makes for more fluid gameplay. I also like to shoot and hear the enemy explosion sound effect a couple times, since the sound resets it sounds cool when you rapid fire an enemy and now with animation state verification I don’t have to worry about points being awarded several times for one enemy.
That about wraps it up for today. This weekend’s plan is to finish the 2D Course EXTRAS, spend some time polishing, adding some additional enhancements to the SHOOTER and if I have time jump into the C# survival guide before moving on to the next Course.