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

加入VIP,免费下载
 

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

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

下载须知

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

版权提示 | 免责声明

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

Unity3dFPS游戏教程3.docx

1、Unity3dFPS游戏教程3FPS游戏教程3Part 3: Advanced FPS 第三部分 高级FPSThis advancedlevel tutorial extends upon the previous FPS tutorials by introducing game elements such as waypoints, enemy AI, ragdolls and animation.这个高级教程是原先FPS教程的延伸,介绍游戏元素,例如路径点、敌人,布偶和动画。Prerequisites 先决条件This tutorial assumes that you are fami

2、liar with the Unity interface and basic scriptingconcepts. Additionally, you should already be familiar with the concepts discussed inPart 1 and 2 of the FPS tutorial series.这个指南已经默认了你已经熟悉了Unity界面和基本的脚本概念。你已经熟悉了第一部分和第二部分的FPS概念的讨论。Setting up设置Were going to build upon the previous FPS tutorial, so wel

3、l begin by opening that:我们将延伸我们的FPS教程,让我们开始吧: Open the previous project (FPS Tutorial 2).打开原先的项目(FPS 教程 2)Waypoints 路径点This section will introduce waypoints to our game, these are used to inform the robotsof the path that they can walk around. Lets add three waypoints to our game:这一节将介绍路径点到我们游戏中,即告知

4、机器人它们能够在周围巡逻的路径,让我们增加三个路径点到我们游戏中:Create an empty game object and rename this to Waypoint. Make sure the game object is placed approximately one meter above the ground level.建立一个空的游戏对象并且重命名它为路径点(Waypoint),确保游戏对象被定位在地面上大约一米左右。Add AutoWayPoint script to Waypoint. Notice how the empty game object now di

5、splays a W in the Scene View.给路径点增加一个自动路径点(AutoWayPoint)脚本,注意怎么在场景视窗中显示空游戏对象(按W键)Duplicate the WayPoint game object twice and arrange the waypoints in a triangleshape (position quite far apart).重复制作两个路径点游戏对象并且把它们排成一个三角形(距离远一些)Check that the waypoints are visible to each other by firstly clicking on

6、any waypoint then selecting Update Waypoint from the context menu of the AutoWayPoint script (the rightmost button on the component in the Inspector View). A green line will be drawn between visible waypoints, a red line for those which dont have a clear line of sight.检查一下这些路径点应该是彼此可见的,首先单击任一个路径点然后在

7、自动路径点(AutoWayPoint)脚本的关联菜单上选择更新路径点(在检查视窗的组件上的最右边按钮),一个绿色的线将在可见的路径点之间画出来,一个红色的线表示视野中没有清晰的线。We have now described the path that an enemy can walk around, now lets add an opponent to the scene.我们现在说明的是一个敌人的巡逻路线,现在让我们在场景中增加一个敌人。Robot AI 机器人人工智能This section will add an enemy robot to our scene.这一节将增加一个敌人

8、在我们的场景中。Select Robot Artwork/robot and drag it into the Scene View making sure all of the robot is above the ground.在Artwork/robot目录下选择机器人(Robot)并且拖拽它到场景中,确保所有的而机器人都在地面之上。Lets give the robot some behavior.让我们给出机器人的一些行为。Add WeaponsScripts/AI to robot. In the AI script section or robot, assign the FPS

9、controller as the target (so the robot knows who to hunt down).增加一个WeaponsScripts/AI脚本给机器人。在AI脚本部分或机器人,都要将FPS控制器作为目标(所以机器人才能知道猎捕谁)Add the AIAnimation script to the robot. This controls the animation of our robot (when to run, when to aim etc). This communicates with the AI script to find out what th

10、e AI script is currently doing, e.g. are we running, shooting etc.It then crossfades the animations to provide a smooth transition.增加一个AIAnimation脚本给机器人,这些会控制我们机器人的动画(什么时候跑,什么时候瞄准等等)。与人工智能进行交流,找出AI脚本当前应该做什么,例如,我们正在跑,射击等。然后他排演一个动画以提供一个平滑过渡。Now we need to make the robot controller object a little larg

11、er so that he doesnt intersect with the ground. This is because the character controller which is used to prevent the enemy from moving through walls is using a capsule to represent the AI. We need to make this capsule a little larger to match the actual graphics, this way he will not intersect with

12、 the ground anymore.现在我们需要建造一个机器人控制器对象,稍大一点,以便它不会和地面相交。这时因为胶囊代表的人工智能使用的特性控制器(character controller)会阻止敌人穿墙移动。我们需要制造稍大一点的胶囊以匹配实际的图像,这样他不会再与地面相交。Select the robot, then in the Inspector View modify the height and radius valuesof the Character Controller component so that it encloses the robot. Press pla

13、yto make sure it works correctly.选择机器人,然后再检查视窗中编辑特性控制器组件的高度和半径值以便它能包住机器人。按运行按钮确保它工作正确。Try making the height and radius values smaller and larger to see the difference.试着将高度和半径值改的稍大一些看看有什么不同。Now we need to give the robot the ability to fire his gun. The robot is continuously moving and animating. Whe

14、n he shoots his gun we play an animation on the hands and the graphical gun then spawn the rocket from transform relative to the robot. This transform does not animate, it is simply placed approximately at the point where the gun will be when the shoot animation fires the rocket.现在我们需要给机器人的枪开火的能力。该机

15、器人在不断移动和动画(用动画表现其反应),当拍摄它手上的枪时我们播放一个动画和枪的图形然后相对于机器人变形衍生出火箭。这个transform不能做成动画,它很简单地大约放置在枪将发射火箭弹的动画的那个点。Create an empty game object and make it a child of the robot (use the hierarchy view).建立一个空的游戏对象并且确保它是机器人对象的子对象(使用层次视窗)Rename the game object gun_spawn.重命名游戏对象为gun_spawnNow we need to place it prope

16、rly. In the transform inspector select Reset from the context menu, then move it forward in the z-axis.现在我们需要配置它的属性。在关联菜单上的transform检查器中选择Reset,然后沿Z轴移动它。Add the rocket launcher script to the gun_spawn game object. Assign the rocket prefab to the projectile variable.增加rocket launcher脚本到gun_spawn游戏对象上

17、,分配火箭预制物体到projectile变量上。Make a prefab of this robot, call it Robot. This will allow you to create more enemies easily.制造一个机器人预制物体,调用它,这将允许你建立更多的敌人。Play the game and check that the robot fires at you.运行游戏并且检查那个朝你开火的机器人。Although you can shoot the robot, it is not configured to take damage, well remedy

18、this in the next section.尽管你能朝机器人射击,但它没有配置获得伤害,在下一节中我们将补救这些。Robot Damage 机器人伤害Attach the CharacterDamage script to the Robot prefab.附着CharacterDamage脚本到机器人预制物体上。Play the game, shoot the robot with the machine gun and he should disappear.运行游戏,用机枪朝机器人射击并且它会消失。Ragdolls 布偶Ragdolls emulate a natural skel

19、etal bone structure, this will allow our robot to fall naturally when killed. This section will show how to setup a ragdoll.布偶模仿一个天然的骨骼结构,这些将允许我们的机器人在被杀死时自然跌倒,这一节将显示如何设置一个布偶。Firstly, create a new scene (File New Scene). Were going to setup our ragdoll in here. Save your current scene if necessary.首先

20、,建立一个新的场景(File New Scene)。我们将在这装配我们的布偶,如果需要保存你当前的场景。Create a cube (resize if necessary), this will be used as a platform for our robot. Drag in the robot to the Scene View so that it is positioned above the cube.建立一个cube(如果需要就重定义一下尺寸),这将被用作我们的机器人的平台,拖拽机器人到场景视窗中以便它被定位到cube之上。Remove the animation comp

21、onent. This is important otherwise the animations will interfere with the physics.删除动画组件,这一点很重要,否则动画在物理上将被干扰。Now use the ragdoll wizard: Game object Create Other Ragdoll. 现在使用布偶向导:Game object Create Other RagdollA dialog box appears, now we have to assign all the bones to the correct slots in the wi

22、zard. We assign the bones by dragging the values from the Robot in the Hierarchy View onto the correct place in the dialog box. Expand the Robot gameobject in the Hierarchy View if necessary to reveal this.出现一个对话框,现在我们必须在向导的正确插槽中指定所有的骨头,我们通过拖拽层次面板上的值分配机器人的骨头到对话框中正确的地方,如果需要在层次视窗中扩大机器人游戏对象以显露出它。Firstl

23、y, rootHandle (Hierarchy View) maps onto root (in the dialog box). Drag rootHandle onto the placeholder beside root in the dialog box.首先,rootHandle(层次视窗)映射到root(在对话框中),拖拽rootHandle到对话框的root旁边的定位手柄处。Set Total Mass to 4设置总质量为4Legs 腿Assign upleg_L to Left Hip.分配左大腿(upleg_L)到Left Hip。Assign lowleg_L goe

24、s to Left Knee.分配左小腿(lowleg_L)到Left KneeAssign heel_L goes to Left Foot.分配左脚踝(heel_L)到Left FootRepeat for the right leg.重复分配右腿Upper body / Arms 上半身和胳膊Assign upArm_L goes to Left Arm.分配左手(upArm_L)到Left ArmAssign elbow_L goes to Left Elbow.分配左肘(elbow_L)到Left ElbowRepeat for the right arm.重复分配右手Assign

25、spine 3 goes to Middle spine.分配脊柱3到中间脊柱。Finally, head goes to Head.最后头部到头部Hit create then press play, the robot should fall, however the gun wont.单击建立并运行游戏,机器人将会倒下,然而枪没有这样做。To make the gun fall:制造枪落下:Select the gun in the Hierarchy View.在层次视窗中选择枪Add a rigidbody component.给它增加一个刚体组件。Add a box collide

26、r. Adjust the size of the box collider to fit the gun, youll needto adjust the center position also.增加一个盒子碰撞器,调整盒子碰撞器的尺寸以适应枪的大小,你也需要调整位置中心。Now we put the fully rigged robot into a prefab. To create the prefab:现在我们把这个全操纵机器人放到预制物体中,建立这个预制物体:Assets Create Prefab.Rename it to RobotRagdoll.重命名它为机器布偶Drag

27、the robot (root level) from the hierarchy view into the prefab. This will make sure the gun is attached also.从层次视窗中拖拽机器人(根层)到预制物体上,这将确保枪也附带着放进去。Now when the robot is killed, we delete the old robot and instantiate the new ragdoll robot, this allows our robot to fall to the ground naturally.现在当机器人被杀死

28、时,买我们将删除老的机器人并且初始化一个新的玩偶机器人,使我们的机器人很自然的倒在地面上。Using the Ragdoll 使用布偶Open the original scene (no need to save the current scene), select the robot from the Hierarchy View and in the Character Damage inspector, drag in the RobotRagdoll prefab to the Dead Replacement.打开一个原始场景(不需要保存当前场景),从层次视窗中选择机器人并且在伤害

29、特性检查器中,拖拽一个机器人玩偶预制物体到死亡替代物上。Play the game, shoot the robot and it should now fall down when shot.运行游戏,朝机器人射击当射中时可以看到机器人会倒下You may want to tweak the mass of the robot to improve the look & feel of the ragdoll. You can do this in the ragdoll wizard, by changing the mass property. This is especially im

30、portant in explosion forces where the robot is thrown into the air.你可能想调整一下机器人的质量以改善机器玩偶看到的感觉。你能在机器玩偶向导中通过改变质量属性做到。当机器人手爆炸影响被抛到空气中时这点特别重要。Sound 声音This section will add sound effects to our game.这一节将给我们的游戏增加声音效果。Machine gun 机枪Drag machineGunSingleShotLoopable onto the MachineGun gameobject.拖拽machineG

31、unSingleShotLoopable声音文件到机枪游戏对象上Turn off Play on Awake.关闭Play on AwakeRocket Launcher 火箭发射器We want to attach the sound source of the rocket to the rocket so that the audio levels reduces as it flies away.我们想附加一个火箭弹声音源到火箭弹上,以便随着它的飞行,声音的大小也在减弱。Select the Rocket prefab.选择火箭弹预制物体Add an Audio Source component to the prefab.增加一个声音源组件到预制物体上Drag the RocketLauncherFire audio source to the Audio Clip property of the Audio Source.拖拽RocketLauncherFire声音文件到声音源的Audio Clip属性上。Adjust the Rolloff Factor so that the sound fades out faster (0.5 might be ok).调整Rolloff Factor以便声

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

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