I have decided to go through the tutorials one last time to ensure that I have followed the steps and hopefully the issues have solved.
There are as shown below:
- NPCs not destroyed after contact
- Enemies shoot backward
- Explosion showed on different location but not on enemies
For the first issues, I went through the tutorials and discovered that the code was caused the NPCs to be remained in the computer’s memory because the syntax for destroying objects outside the game. In other words, once it has been destroyed it should not remain in the computer’s memory which explains why that the game during runtime was so low after the first NPCs wave.
To solve this, there should be a code to detect if the object or models is outside the boundary then it should get destroy. Also to ensure the game does not lag during runtime, there should be another code to ensure that if any objects and models are out of sight then it will be destroyed after a certain time to ensure that everything are completely destroyed.
For the second issue, enemies are shooting into the wrong direction. This is because that the shot spawn was in the wrong direction. Also I was not sure how to implement the enemy to shot randomly in a random time and also display on stage in a random wave. The reason for this, it that I wanted random enemies to show up at a random time in each wave so the player will not be able to predict when and where those enemies will show up during gameplay.
To solve this, there should a number of random methods to determine and hold the custom values to instruct number of waves shown on stage and each wave should have a mixture of NPCs and enemies that attack the spaceship. Also the shot spawn need to be rotated 180 degrees to allow enemies to shoot towards the spaceship.
For the third issue, explosion was not displayed on the same location as the enemy to indicate a successful elimination. I still not sure why this has happened because those NPCs has the similar settings expect that it will not shoot at the spaceship. I have tried to recreate the enemy but still unsure which part case this issue.
To solve this, I tried to duplicate another NPC which contains the similar settings and replace it with the enemy then reconnect with the enemy script. Have several attempts, the enemy has finally worked as I run the game and shoot at the enemy, the enemy destroyed and display an explosion in the right time and place.