Unity3d_FPS游戏教程2.doc

  1. 1、本文档共25页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Unity3d_FPS游戏教程2

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:这个脚本代码: function Awake() { // Select the first weapon 选择第一个武器 SelectWeapon(0); } This function initializes weapon 0 as the default weapon. 这个函数初始化武器0 为缺省的武器。 function Update() { // Did the user press fire?用户按开火? if (Input.GetButton (Fire1)) BroadcastMessage(Fire); if (Input.GetKeyDown(1)) { SelectWeapon(0); } else if (Input.GetKeyDown(2)) { SelectWeapon(1); } } 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. function SelectWeapon(index : int) { for (var i=0;itransform.childCo

文档评论(0)

gangshou + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档