unity3d FPS游戏教程2

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

FPS游戏教程2

Part 2: Enhancements第二部分增强

This intermediate-level tutorial

extends upon the Basic FPS tutorial

by introducing game elements such

as multiple weapons, damage and

enemies.

这个中级教程是FPS基本教程的扩展,介绍游

戏元素例如多种武器、毁伤和敌人。

Prerequisites

This tutorial assumes that you are familiar with the Unity interface and basic scripting concepts. Additionally, you should already be familiar with the concepts discussed in

Part 1 of the FPS tutorial series.

这个指南已经默认了你已经熟悉了Unity界面和基本的脚本概念。你已经熟悉了第一部分的FPS 概念的讨论。

Before we begin -level setup

在我们开始层面设置之前

Download FPS_Tutorial.zip, unzip, and open the project folder in Unity. If you

have completed Part 1, then unzip the files to a new folder.

下载FPS_Tutorial.zip解压缩并且在U你体验中打开项目,如果你有已完成的第一部分,这时解压缩它们到一个新的目录。

Import the Standard Assets Unity Package.

导入Standard Assets标准资源包

Add the mainLevelMesh and FPS controller prefab to the scene.

增加mainLevelMesh和FPS控制预制物体到场景中。

NOTE In this tutorial no new scripts need to created. We’ll be using the ones that

were downloaded from the Unity Package.

注意在这个指南中没有新的脚本需要建立,我们将使用下载的Unity软件包中的一些东西。

Weapon switching 武器开关

Before we discuss how to create each individual weapon, we need to write some code to manage how the weapons are initialized and switched from one to another. Let’s look at the Javascript for PlayerWeapons.js:

在我们讨论如何建立每一个个体的武器之前,我们需要写一些代码以便管理这些武器怎么被初始化并且能被另一个(武器)关闭,让我们看一下PlayerWeapons.js:这个脚本代码:

This function initializes weapon 0 as the default weapon.

这个函数初始化武器0 为缺省的武器。

This function detects keyboard input; the fire button, the “1” button for weapon 1 or the “2” button for weapon 2. The weapons will be children objects of the Main Camera.

这个函数检测键盘输入;开火按钮,‚1‛按钮是武器1,‚2‛按钮时武器2。武器将被作为主照相机的子对象。

This activates the corresponding weapon depending on keyboard input.

Let ’s use the above code.

激活响应的武器依赖键盘输入,让我们看上面的代码

Create an empty game object called Weapons. Move this so that it is a child object

to Main Camera (inside FPS controller). Our weapons will be added as children

of this object.

建立一个空的叫‚Weapons ‛的游戏对象,移动它以便将它作为主照相机的子对象(在FPS 控制器内),我们的武器将被增加为它的子对象。

Assign the PlayerWeapons.js script to the Weapons game object under Main

Camera.

分配PlayerWeapons.js 脚本到主照相机下的Weapons 游戏对象上。

We ’ll now create our first weapon.

我们将建立我们的第一个武器

Rocket Launcher 火箭发射器

This section will describe how to make a rocket launcher style weapon.

这一节将描述如何制造一个火箭发射器类型的武器

Launcher 发射器

The rocket launcher is responsible for instantiating a rocket and giving it an initial velocity. The rocket will be launched directly at wherever the user is pointing and will be destroyed

相关文档
最新文档