Day 13: Blowing Up The Asteroid Ghost
Unfortunately, Unity crashed on my computer today. I didn’t lose too much work, but I really should save more often and frequently so that this doesn’t happen again. Lesson learned.
So, today I had to make the lasers be able to shoot the asteroid and make it explode at the same time. For the longest time, I could not get it to work. The asteroid was a ghost to my lasers. I had the collider method up, I called out the lasers in tag form “(other.tag (“Laser”)” on, I made sure that the gameObject would be destroyed (asteroid), and I made sure that the laser too would be destroyed. I thought everything was all good, seemed simple enough, but then that happened.
Disappointed at myself I looked over the coding again, made sure I had all the right words and logic sequence was correct and then I noticed after much effort and a growing headache that I was missing 2D in the line.
Instead of having this:
void OnTriggerEnter2D(Collider2D other)
I had this:
void OnTriggerEnter2D(Collider other)
I don’t even know how it happened. I swear it was there, but obviously, it wasn’t. Truly one must pay very close attention when coding, I can’t begin to say how frustrated I was when I believed that I had done everything right to make the effect of destroying the asteroid.
At the same time of my frustration of such a small mistake, I am also proud of myself for being able to complete the challenge without having to even research what I needed to do. It’s not very often that I remember these new words and their functions, but all of this repetition, our great teacher Jon, and my stubbornness is beginning to take root after 12 days of hard work (not to mention the time I spend figuring this out when I’m not on the clock).
Thankfully after that frustrating user error (me), instantiating the animation of the explosion over the asteroid did not give me too many issues. So in the end, even though I am a bit slow in figuring the coding out right now, I was finally able to be rid of the ghost asteroid and made it explode when it was shot by my lasers.
I hope to never make such a simple mistake again, but I doubt it. All I can do is to continue to grow from my mistakes and try not to let them shut me down and become frustrated as I did today. Tomorrow is a new day, and I can’t wait to continue to grow in so to pursue a future as a Unity Dev Engineer (hopefully it is not something that is out of my grasp).