I’m happy to report that, after a considerable amount of time, yesterday’s hurdle has been overcome. That is, the enemy’s laser fire is acting properly.
I was able to deduce that the issue was not in the script, by using several Debug.Log and Debug.break commands throughout the process. I noticed the error when Debug.break paused the game right when an enemy was instantiated. It would seem as though the enemies were being instantiated with the laser prefab in front of them, as opposed to the lasers being instantiated when called by the script. I was able to confirm this by zooming in on the scene view.
Allowing the script to call the instantiation of the enemy’s laser solved the problem. In this case, Unity’s hierarchy was the place to go for the solution. I unchecked the enemy laser and the enemy fire acts as expected.
Next, I utilized the OnTriggerEnter method on the laser’s script, since the laser already had a rigidbody component. When the enemy’s laser collides with the player, the damage method is called on the player script.
Using the game manager, I added Application.quit() for when the user presses the escape key. This is is a necessary feature before deployment. At this point, I had completed the galaxy shooter extras, and was ready to move on to phase 1: framework.
I’m so excited to jump in to this section. There are no tutorial videos, no challenge reviews. Just a set of objectives, the software, Google, and me! I anticipate tackling the camera shake, the health powerup, and ammo count/ammo collectable first. I wrapped up the loops section of the survival guide today as well.