官术网_书友最值得收藏!

Planning and creating our enemy

We have a player that moves, shoots, and takes damage; we can now start looking into creating an enemy that shares these attributes.

To remind ourselves of the genre we are making, our game carries the same traits as classic arcade shooters such as Konami's Gradius, Capcom's UN Squadron, and Irem's R-Type (https://raw.githubusercontent.com/retrophil/Unity-Certified-Programmer-Exam-Guide/master/Reference/shootEmUps.jpg). Typically, with these types of games, the player is swarmed by enemies coming from the right of the screen and exiting to the left.

In this section, we will be repeating similar aspects of the PlayerSpawner and Player scripts. The EnemySpawner script needs to be tweaked so that it will instantiate a given number of enemy ships at a certain rate.

The Enemy game objects will be moving on their own, so there needs to be some extra code applied to their behavior. Before we go into creating our first enemy script, let's look at a part of our game framework and note the layout is basically the same as the player's side of the game framework:

Before we jump into the EnemySpawner script, let's do the same housekeeping we did for our player game objects, namely creating an empty game object and storing all game objects relating to it in that one game object. The reason we did this is to remove the clutter in the Hierarchy window, so let's do the same for our enemies:

  1. Right-click in the Hierarchy window's open space.
  2. A drop-down list will appear, select Create Empty.
  3. Name the game object _Enemies.

Let's move on to our enemy scripts.

主站蜘蛛池模板: 安图县| 西乌珠穆沁旗| 镇坪县| 南部县| 拉萨市| 莲花县| 克什克腾旗| 无棣县| 汽车| 青铜峡市| 武川县| 出国| 石阡县| 高青县| 晋中市| 广汉市| 合肥市| 阿图什市| 讷河市| 苗栗市| 前郭尔| 新蔡县| 报价| 朝阳县| 广元市| 华宁县| 扎鲁特旗| 海南省| 中阳县| 荆门市| 汤原县| 寿宁县| 蒙阴县| 壤塘县| 阿坝| 布拖县| 胶南市| 高要市| 潢川县| 扬州市| 临邑县|