Aloha everyone and happy Monday! I have not written in a few weeks about my progress and thought today would be a great day to review some of the things I have accomplished in my program. Today also marks day 52 of my 100 day coding challenge to myself which puts me at just over half way for both programs. The last few weeks have been especially challenging with the concepts I have learned and put to use. Week 3 focused mainly on a trigger system for enemy detection using OnTriggerEnter, OnTriggerStay, and OnTriggerExit. Week four went into some of our UI elements and creating a really cool dissolve shader effect for when the enemies die.
Here is a quick photo of my targeting system at work. If you look closely you can see a green and blue line that represents the targeting system for both the enemies and the gun turrets. The green dome shape is what is called a collider and it serves the purpose of detecting when something has, hit, or is within its boundaries. The OnTriggerEnter function is a great build in feature of Unity that allows you to detect these collisions from the collider. You can get so much information from that collision including the GameObject that collided with you. Then there is OnTriggerStay and this method works very similar to the update function. It is good for calling things like movement and ray-casting functions here as they need constant updating. And of course OnTriggerExit is called every time an object leave your collider. This can be very helpful when targeting because you would not want to target an enemy that is no longer within your collider.
On top of using those functions I also learned about OnMouseEnter, OnMouseDown, and OnMouseOver, and On Mouse Exit. These are very powerful built in functions that detect the mouse movement and can pass along information. With the on mouse over for instance, I can use this to detect which GameObject I am over, and then pass that information to anyone who would need it. Say for instance a UI manager wanting to know what object we are over and if it can be upgraded. Part of my continued journey has been learning to use Events more often and avoiding GetComponent as much as possible. This is part of creating optimized Object Oriented Programing.
To finish out week 4 there was lots of work with our UI system. I added the function of upgrading into my game. Now you can select an existing tower and upgrade that tower though our UI system. The amount of funds you have is also tracked the whole time. There were many challenges with this part and lots of connecting GameObjects to the UI manager. But I have to say I am feeling more and more confident using events now and besides a few little bugs that popped up today, my game is working great. Here is a sample of the upgrading process, and as always Mahalo for taking the time to read.