I can’t tell you how relieved I am to have finally completed the User Interface section. I was mulling over the coding and why it works the way it does for days, trying to understand it so I would be able to use it/recall it without having to go through the same challenges. But none the less, “It will kill”! No, I mean it works! It bloody works. It feels so good to have this accomplishment (albeit a small one).
[That quote is from one of my favorite shows “Forged In Fire”]
Completing the UI, I was able to move on to VFX, or the Effects section, and added my enemy being destroyed animation as well as working out the rotation of the Asteroid GameObject with little help (or just skipping through the videos for the answer).
The enemy destruction animation took a little more time to get working as I did not realize that the enemy prefabs were being destroyed right away. But once that was figured out, I also added to remove the rigidbody2d component as well as the boxcollider2D so that the lasers would pass through the animation and destroy spawning enemies that happen to come from behind the enemy that was just destroyed. This I must admit is much more fun to do than the coding alone (being able to fine-tune these game mechanics so the game looks better, and feels better to play, is quite enjoyable in comparison to the coding, but I want to be able to do it all well).
The last part I worked on today was the asteroid, which brings me to the title of this blog “Flipping Asteroid”. I made a coding error that caused my asteroid to flip vertically (remember this is a 2D object so it’s actually flat), which made it look like an asteroid coin flipping in place…it was quite hilarious watching it).
My original code looked like this:
transform.Rotate(Vector3.right, 35 * _speed * Time.deltaTime);
But I was able to fix it by doing this instead:
transform.Rotate(0, 0, Random.Range(5, 25) * _speed * Time.deltaTime);
Having the other axis’s in after Rotate made a big difference.