ImageVerifierCode 换一换
格式:DOCX , 页数:41 ,大小:1.29MB ,
资源ID:9389785      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/9389785.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(Unity3dFPS游戏教程2.docx)为本站会员(b****8)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

Unity3dFPS游戏教程2.docx

1、Unity3dFPS游戏教程2FPS游戏教程2Part 2: Enhancements 第二部分 增强This intermediate-level tutorial extends upon the Basic FPS tutorial by introducing game elements such as multiple weapons, damage and enemies. 这个中级教程是FPS基本教程的扩展,介绍游戏元素例如多种武器、毁伤和敌人。PrerequisitesThis tutorial assumes that you are familiar with the Un

2、ity interface and basic scriptingconcepts. Additionally, you should already be familiar with the concepts discussed inPart 1 of the FPS tutorial series.这个指南已经默认了你已经熟悉了Unity界面和基本的脚本概念。你已经熟悉了第一部分的FPS概念的讨论。Before we begin -level setup在我们开始层面设置之前 Download FPS_Tutorial.zip, unzip, and open the project fo

3、lder in Unity. If youhave 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控制预制物体到场景中。N

4、OTE In this tutorial no new scripts need to created. Well be using the ones thatwere 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 init

5、ialized and switched from one to another. Lets 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.

6、这个函数初始化武器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

7、 for weapon 2. The weapons will be children objects of the Main Camera.function SelectWeapon(index : int)for (var i=0;i reloadTime + lastShot & ammoCount 0)/ create a new projectile, use the same position and rotation as the Launcher./就像发射器一样,在同样的位置建一个新的发射体var instantiatedProjectile : Rigidbody = In

8、stantiate (projectile,transform.position, transform.rotation);/ Give it an initial forward velocity. The direction is along the z-axis of/ the missile launchers transform./给它一个初始方向速度,沿着导弹发射器的Z轴instantiatedProjectile.velocity = transform.TransformDirection(Vector3 (0, 0, initialSpeed);/ Ignore collis

9、ions between the missile and the character controller/在导弹和特性碰撞器之间忽略碰撞/译者注:有时我们不太注意,将发射点放到了玩家或发射武器内了,而武器和弹药都有碰撞属性,为防止发射出去的弹药乱飞,下面这句非常必要Physics.IgnoreCollision(instantiatedProjectile.collider, transform.root.collider);lastShot = Time.time;ammoCount-;This code ensures that the weapon cant fire faster t

10、han reloadTime. It also checks that the user can fire only when they have sufficient ammo.这段代码确保了武器开火速度不能比重装(弹药)的时间还快,它还可以检查用户是否有足够的弹药开火The behavior for the RocketLauncher is similar to that in the previous FPS tutorial with the exception of the reload time and ammo count described above.这个RocketLau

11、ncher的行为与以前的FPS教程中的相似,除了上面所说的重载时间和弹药计数以外。Attach the RocketLauncher.js script to the RocketLauncher game object. Make sure that you are not attaching this script to the rocketLauncher child game object.附加RocketLauncher.js脚本到RocketLauncher游戏对象上,要确保你不是把脚本附加到rocketLauncher子游戏对象上了。Rocket 火箭We will now bu

12、ild the rocket in the scene and upload the final version to a prefab.我们现在在场景中构建火箭并且上载最后的版本到一个预制物体上。Click on Objects/weapons/rocket in the Project window and make sure that the FBXImporter Scale Factor is set to 1, otherwise the model will import at a very small scale.在项目窗口的Objects/weapons/rocket上单击并

13、且确保FBXImporter Scale Factor(比例因子)被设置为1,模型将以一个非常小的比例被导入Drag the Objects/weapons/rocket model into the Scene view.拖拽Objects/weapons/rocket模型到场景视窗中。Attach the WeaponScripts/Rocket.js script to it.附加WeaponScripts/Rocket.js脚本给它Add a box collider to the rocket game object. Make the box collider slightly l

14、arger than the actual rocket to prevent tunneling of collisions. Tunneling of collisions is what happens when small, fast game objects avoid collision detection due to their size and speed. Making the box collider z-axis larger ensures collisions work correctly for these objects.增加一个盒子碰撞器给火箭游戏对象。使盒子

15、碰撞器稍稍大于实际的火箭,以阻止穿透碰撞。当碰撞器很小时穿透碰撞就会发生,快的游戏对象避免碰撞检测取决于它们的尺寸和速度,使得盒子碰撞器的在Z轴变得更大以确保这些对象的碰撞工作能正确的发生。In the Rigidbody of the rocket game object, deselect Use Gravity. This ensures that the rocket does not fall under gravity.在火箭游戏对象的刚体中,不选择使用Use Gravity选项,这能确保火箭不会再重力作用下坠落。Create a particle system: Game Obj

16、ect Create Other Particle System.建立一个粒子系统:Game Object Create Other Particle SystemModify the Ellipsoid x,y,z sizes to 0.1.编辑Ellipsoid的X、Y、Z的尺寸到0.1Modify the Rnd Velocity to 0.1 in each axis also.编辑Rnd Velocity的每个轴向数据到0.1Change the particle emitter Min Size and Max Size to 0.5.改变例子发射器的最小尺寸和最大尺寸到0.5Ch

17、ange the number of particles emitted to 100 (Min and Max Emission).改变粒子发射器的数目到100(最小和最大排放物数目)Drag the Particle Effects/smoke onto the particle system.拖拽粒子效果/烟雾到粒子系统上In the Particle Animator section, set each of the World Rotation Axis values to 0.5.在例子的动画片段,设置每个世界旋转轴的坐标值为0.5Set the Size Grow variabl

18、e to 3.设置尺寸生长变量到3Enable Autodestruct on the particle system. This ensures that the particle system is removed from the game after the rocket has been destroyed.选中粒子系统中的自毁选项,这能确保在火箭被销毁以后粒子系统也能被从游戏中删除Drag the particle system in the Hierarchy View so that it is a child of the rocket. Reset the transfor

19、m of the particle system so that it is centred on the rocket,then modify the position so that it is at the rear of the rocket.在层次视窗中拖拽粒子系统以便它作为火箭的一个子对象,重设粒子系统的transform以便它位于火箭的中心,然后编辑它的位置让它靠近火箭。Select the rocket in the Hierarchy view and check that the smoke trail follows it around in the Scene view

20、 if you move it around.在层次视窗中选择火箭并且在周围移动它,在场景视图中检查烟尾。Weve now made our rocket, complete with smoke trail. Were now ready to uploadour changes to the prefab. 我们现在制造火箭,完成烟尾.准备上载(火箭)到预制物体中。Firstly, create an empty prefab to upload our changes to. Call the prefab Rocket.首先,建立一个空的预制物体以上载我们的改变,叫预制物体为Rocke

21、tSelect the rocket in the Hierarchy view and drag it onto the new Rocket prefab.在层次面板视窗中选择火箭并且拖动它到新的火箭预制物体上。Create a new directory in the Project view called WeaponPrefabs to store our weapon prefabs in.在项目视窗中建立一个新的目录叫WeaponPrefabs,在里面存储我们的武器预制物体。Heres the Javascript for Rocket.js:/ The reference to

22、 the explosion prefabvar explosion : GameObject;var timeOut = 3.0;/ Kill the rocket after a while automatically/一会儿自动销毁火箭function Start () Invoke(Kill, timeOut);这里是Rocket.js的Javascript脚本The Kill function, firstly, finds the particle emitter in the child hierarchy and turns its emitter off. Next, it

23、detaches any children (e.g. Smoke trail particle system) from the object the script is attached to (the rocket) and destroys the rocket.Kill函数,首先,在子层次上找到粒子发射器并且关闭它的发射,下一步,它被分派到被附加脚本的对象的另一个子对象(例如烟尾粒子系统)并且销毁火箭。function OnCollisionEnter (collision : Collision) / Instantiate explosion at the impact point and rotate the explosion/在碰撞点初始化爆炸物体并且调整爆炸物体方向/ so that the y-axis

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1