Unity3d_FPS游戏教程3

发布时间:2023-02-08 19:22:01

FPS游戏教程3Part3:AdvancedFPS第三部分高级FPSThisadvancedleveltutorialextendsuponthepreviousFPStutorialsbyintroducinggameelementssuchaswaypoints,enemyAI,ragdollsandanimation.这个高级教程是原先FPS教程的延伸,介绍游戏元素,例如路径点、敌人AI,布偶和动画。Prerequisites先决条件ThistutorialassumesthatyouarefamiliarwiththeUnityinterfaceandbasicscriptingconcepts.Additionally,youshouldalreadybefamiliarwiththeconceptsdiscussedinPart1and2oftheFPStutorialseries.这个指南已经默认了你已经熟悉了Unity界面和基本的脚本概念。你已经熟悉了第一部分和第二部分的FPS概念的讨论。Settingup设置WeregoingtobuilduponthepreviousFPStutorial,sowellbeginbyopeningthat:我们将延伸我们的FPS教程,让我们开始吧:Openthepreviousproject(FPSTutorial2.打开原先的项目(FPS教程2Waypoints路径点Thissectionwillintroducewaypointstoourgame,theseareusedtoinformtherobotsofthepaththattheycanwalkaround.Letsaddthreewaypointstoourgame:这一节将介绍路径点到我们游戏中,即告知机器人它们能够在周围巡逻的路径,让我们增加三个路径点到我们游戏中:CreateanemptygameobjectandrenamethistoWaypoint.Makesurethegameobjectisplacedapproximatelyonemeterabovethegroundlevel.1
建立一个空的游戏对象并且重命名它为路径点(Waypoint),确保游戏对象被定位在地面上大约一米左右。AddAutoWayPointscripttoWaypoint.NoticehowtheemptygameobjectnowdisplaysaWintheSceneView.给路径点增加一个自动路径点(AutoWayPoint)脚本,注意怎么在场景视窗中显示空游戏对象(按W键)DuplicatetheWayPointgameobjecttwiceandarrangethewaypointsinatriangleshape(positionquitefarapart.重复制作两个路径点游戏对象并且把它们排成一个三角形(距离远一些)CheckthatthewaypointsarevisibletoeachotherbyfirstlyclickingonanywaypointthenselectingUpdateWaypointfromthecontextmenuoftheAutoWayPointscript(therightmostbuttononthecomponentintheInspectorView.Agreenlinewillbedrawnbetweenvisiblewaypoints,aredlineforthosewhichdonthaveaclearlineofsight.检查一下这些路径点应该是彼此可见的,首先单击任一个路径点然后在自动路径点AutoWayPoint)脚本的关联菜单上选择更新路径点(在检查视窗的组件上的最右边按钮),一个绿色的线将在可见的路径点之间画出来,一个红色的线表示视野中没有清晰的线。Wehavenowdescribedthepaththatanenemycanwalkaround,nowletsaddanopponenttothescene.我们现在说明的是一个敌人的巡逻路线,现在让我们在场景中增加一个敌人。RobotAI机器人人工智能Thissectionwilladdanenemyrobottoourscene.这一节将增加一个敌人在我们的场景中。SelectRobotArtwork/robotanddragitintotheSceneViewmakingsurealloftherobotisabovetheground.Artwork/robot目录下选择机器人(Robot)并且拖拽它到场景中,确保所有的而机器人都在地面之上。2

Unity3d_FPS游戏教程3

相关推荐