粉丝1161获赞5479

现在的游戏设计都是非常自由的,你比如说,呃,现在应该算是排名第一老大的那种,欧美奇幻的 ipg, 老滚,老滚五就上古剑斗五,我当时开始玩的时候就从三开始玩了,暴露年龄了。就 大家那个在老滚里面可以随意的用这种鼠标滚轮进行一个第三人称和第三人第一人称之间的一个切换。 那我们现在这个 status 可不可以呢?答案肯定是可以的,我现在已经做成,大家可以试一下,刚进去的时候默认是第三人称视角的。好,我们让他开始快跑, 跳到这个主路上,然后咱们再切换一下。路在哪呢?路在这。好切换,我设置是 f 一, 一键点 f 一啊,直接切成第一人称了。切完第一人称,我想返回来,再点一下 f 一,不用回来了。那我们下面就来聊一下怎么实现这个功能。 好,我先把游戏停掉,把它还原,这一块我都给它删掉好没了。这里面我们想要添加第三人称的, 在 tooth status, 然后 resets seventh, fortune, ctrl 了 amateur, 这就出来了。嗯,最好还是用一个什么呀,空的游戏对象 重置一下啊,重置成原始位置,然后把这个空的跟帽子重命名为色的 postenplayer 吧,色的 tiasoplvr 一样。等会呢,第一人称视角我们叫 frostfromplayer, 然后把其他这三个给他扔到这个里面,当做他的子对象,然后一定要注,记住,把他这个按内部给他取消了, 要不然的话,我们在添加第一人称视角的时候,他不会给你添加这些。开门啊。好,接着按 toots statuses first 炕头了。哎,你先添第一,先添第三都行,但是一定记住要添加新的时候,要把旧的他们外部这个包裹的游戏对象给他, 让他失效,就是把他 deactive, 让他那个失效,要不然的话这两个开幕是填不进去的,他 默认这里面的开门啊,他的类型是一样的,他这个工具会自动检测,如果有这个开门的话,他就不会再添加新的了, 所以我们还是再重复创建一个空的新的游戏对象。你看啊,他是出手位置,不需要重置了,那直接就叫 first person player 好,然后把这三个也扔进去。哎,那这个初始的状态就是 first person player 就这样了,那这也行吧。 然后我们就需要再添加一个空的游戏对象,这个游戏对象叫 suv 啊,就是转换视角,切换视角,然后他的功能实际上就是添加一个新的 script。 我们这里面已经创建过一个了啊,我当时测试的时候已经有一个了,那我们把它叫一吧, cvo 一,你到时候写的时候就还叫 suvchvo 就行了,可以谈爱的。好,然后接下来双击打开, 好,这个拿过来,我们来开始准备开发。 我们在这里面其实不需要用到这个 stat, 我们把它取消掉,我们在这需要把这些都获取到。是让我们先来测试一下这个游戏, 你比如说我们运行的时候, 运行的时候你注意看他这里面的这些参数 啊, first percent ctrl 了 player 啊,他这里面穿丝防,我们是不变的,我们切换完以后切换好,切换就让一个 active, 一个点 active 就行了,一个生肖,一个不生肖就行了,直接操作他最外层这个游戏对象就可以,就可以完成切换。但是还有一个很重要的点就是你现在所在位置是不是也要跟着给改变一下啊? 你比如说我现在已经到游戏中间了,你如果要直接切换过来,他里面这些子游戏对象的位置是不是还是出水状态?那就说从那个我已经跑到地图中间了,哎,快打到老怪了。一切到第三人称或者第一人称又跳到那个地图入口点了, 那合理吗?肯定是不行的,对不对?那怎么办啊?我们需要不是实时都获取,在切换之前获取到当前我这个视角所在的这些,呃,模型位置, 呃,这个开幕,开幕的位置也很重要啊,你别那个模型在这个地图中间了,然后摄像机还在那个远点,你都看不见自己了。所以说这三个子游戏对象的位置都需要获取到,那我们就需要先把这些 游戏对象和此游戏对象都在我们代码中,能够给他拿到。拿到,然后拿他的谁啊?川 stop 里面的 pose 性和柔推性是 q, 我们在当前这里面是不会变的,所以说不需要动它,主要就是拿 pos 性和柔推性。那好, 代码的话,首先我们要起几个 public, 最简单的方式是不是还是通过那个?呃,我们在叫什么? inspector 属性窗口里面把海外 k 里面拖过来啊,直接拖转还是比较方便的。那我们就拿着几个,哦,不对,首先拿到 first person player, 然后再拿到,这是第一人称, 第一人称视角游戏外层对象,副对象,外层 空的副对象啊,这个就是他没有任何的那个组建嘛,所以说我们问他叫空的一个游戏对象,他是主要是用来控制我们当前这个视角所有的这些元素是否生效的。 那接下来还需要获取,我其实可以通过这个副对象再去找子对象,但是那样会增加我们代码的复杂度,我们现在暂时不做。那么,呃,那些让大家 就是学的时候比较麻烦的那一些东西,我们先尽可能让你们学的时候简单一点,那我们就不通过副对象来获取子对象,而是直接把子对象也在这里面趴布雷克了一下,然后直接通过那个海尔,可以,可以拖到 inspect 里面吗?这样比较方便。那好, 再来一个给猫,不借它,给猫借给它,这里面就要用到它里面的那个什么东西了,哎,它这里面的一个 follow camera, 一个 player follow camera, 一个 meaaa player 的模型,那好,我们就分别把这三个对象给他拿过来。第一个叫 player follow 啊,就跟随游戏角色的这个虚拟摄像机, 我们叫一,等会,到时候那个另外一个,另另外一组第三人称了,我们给他后面就加一个后退三,这样便于区分就行了,然后这个给 maojit, 就应该是命 comer, 哎,也是,一到时候那个第三人称给他叫三,然后这个还需要有一个 player i play。 二,一,这就里面的模型。那好,这是低人称视角相关对象,这是外层副对象,这是虚拟摄像机, 然后这是主摄像机 啊,这个是什么啊?玩家,玩家占位, 玩家当前位置占位用模型,那这个都是第一人称的,那我们再给他复制一份,那下面这是不是第三人称的了?你如果不想让他 算是给大家布置一个作业吧,你如果不想让前面弄这么多对象,然后通过哈哈,给拖了话,拖到 ins 白个摊里面的话,你只要这第三人称的副对象和第一人称的副对象,然后此对象你通过那个代码去找盖他丘准 是可以的,如果会增加咱们那个代码的复杂度。福尔斯普尔森,这个就不叫了,这叫什么?斯尔的普尔森 surprise from player 这个 playerflow camera 我们叫三,第三人称 amekamura 二幺三不列二也是三。好,这前面都准备好了,到时候直接拖拽就可以了。斯大太,我们不需要,因为我们不需要出手啊,我们在 inspec 里面直接获取啊,不对,他那用一个快捷键, 用老版本的输入系统 get k 档吗?按下的时候按下哪个键呢? k 扣的打 f 一啊。 f 一键的时候我们来进行切换, 他这运行 状态下,我这个机箱一直不停的轰给他暂停了。然后呢,这里面就要先看一下,再来一个衣服,如果 first please first person player 这个点 active 它是否被激活?它如果被激活的话,现在点 fe 是不是应该切换到第三人称视角了? 如果当前是第一人称,则切换为第三人称,那就下面首先是不是获取这些位置? 获取位置的时候 transform 它是一个指读的,你比方我们来看一下啊, player follow camera, 这是一呃,点 transform 等于 player 三对,哎,不对,应该反过来应该是先是三吧,我们要获取,要要切换了,然后前面应该是用一给三复制,三一点穿错 看行不行。哎,这是不行的,因为它是一个指读的川 ceform, 你必须用这样复制才行,它里面有 position, 有 rotation, 有 skill, 我们现在 skill 不需要动。那只需要动什么呀?哎,只需要动那个 肉推心和 position 就行了。肉推心等于好拿肉推心。这个就是 虚拟摄像机位置复制,然后嘞,主摄像机位置是不是也需要复制啊? 主相机的话是 mecomer。 三点 transform their position 啊,等于 player 呃,等于 mean camera 一点儿 transform 点儿 可对性好,那接下来这个复制粘贴 rotation 等于你看不着一点儿 transform 点儿 rotation 好,然后是什么复制啊?就是玩家这个占位 玩家位置,那玩家位置的话 player 三点 transform their position 导演 meng uh play 二一 player 一点儿 transform 点儿 position, 然后同样 player 三点儿 transform 点儿 rotation 等于 player 一 点儿 transform 点儿 rotation 好,这个敷完纸以后是不是要切换他们两个的一个激活状态? 要先把这个 first person player 点儿点儿点儿点儿 sec。 呃,对,他这提示了,正好是 set active 等于 force, 然后 third person player 点儿 sect active 等于什么呀?这就是 true, 让第三人称的激活第一人称的失效。那接下来这 l 四是不是正好反过来就行了? l 四反过来非常简单,那把它全部复制,然后粘贴, 粘贴的时候把这个这个一 三三一一 好,最后是把这个出和 boss 换一下,这个前面换成色的, 然后后面换成 first, 整个这个就可以了。那好,我们把它回到变音器,回到 游泳厅里面, 把我们需要用到的这些游戏对象给他拖拽过来了。首先是 first person player player 是里面的, 里面的这个开不巧, 然后,呃, player follow camera 一是这个 main camera 一,他 player 一, 啊,不对,错了, facebook and player 是副对象,是他这个 player 一才是这个,这个不要搞错了。然后四十 precant player 是他副对象,然后 player follow camera, main camera player sun 好,成了运行试一下。哎,这是刚开始我们第一人称的。好到这,然后我们切换一下 f 一,哎,是不是变成第三人称了? 变成第三人称。然后到这再切换 f 一,又变成第一人称了,第三人称。

各位小伙伴们大家好,今天要给大家聊的就是如何让大家在三分钟之内就做出一个像我现在操作的这样的一个三 d 第三人称视角的游戏模型。 我们还可以把里面的人物替换替换成咱们自己建的模型,比如说我们上次用的这个死白搭们, 哎,这快速的就可以进行一个项目的设置,这里面的这个机器人是不是看着很眼熟啊?哎,对,他就是我们在 ccnma 群里面使用到的这个机器人,他们用的是相同的一个资源包, 对,这是说我说的资源包了,所以说他也不是我们一点一点从零开始创建出来的,而是直接从那个 ics 到里面下载选择,然后在我们这个 windows 拍 window package manager 里面直接下载安装的一个资源包,打开浏浏览器,先到 ss 道上面搜索,搜索什么呢? stattasss 就行了,或者说直接搜索 st prussycarct。 还有一种方式就是用我到时候在视频底下给大家发个链接,在当前这个视频下面我会把链接放上去, 你点进来然后添加,我这是添加过了,他就是显示在有问题中打开了,另外再找一个那种免费的三 d 场景,我这里面找到的是 fantasy for forest environment, 也就是一个叫什么呀? 森林的一个奇幻森林的一个环境包,他也是免费的三 d 的,非常漂亮,也是把它选中然后打开就行了,或者说直接那个 添加添加,然后咱们在拍成 mang 点里面就可以选就可以找到了,这个链接我也会给大家发到当前视频下面。好,这两个暂时就够用了。到我们这里面打开 packy manager, windowprodune manager 啊,搜索,我们先把那个四十 prise, 就是第三人称,是这种控制器给装上,第三人称资源给装上。所以说搜索 status status, ceopulsecometer 了。 ceopolitancocolcometer, 第三人称角色的一个 控制器。你第一次肯定是只有一个当唠的,你点击当唠的,然后再引炮的就可以了。我这因为已经 装过了,我就不再重复操作了,大家可以试一下,很快的,他这个也没多大,才七十多兆。然后再搜索刚才那个反差 c, 一般只搜第一个单词就足够了吗?哎,我这里面反他 c 这个单词开头的包,我以前装加的比较多。那他第一页显示不全,你看右下角有一个 显示多少,你给他显示选中哦,就是全选全显示,然后根据他的那个名字来找 fantasy environment, forest environment 这个 freedam。 你如果要前面加的这个资源包少的话,你肯定找的很快了,然后也是同样的,当 in pot 就可以了。进来以后我们在这个 fantasy forest environmental 中, 我把这上面东西都先删掉啊,他默认的应该就是这个样子, 把其他的暂时先删去,他默认是这个样子。在哪啊?在我们的 fantastic forest environment free example, 然后找 scene, scene 是哪一个?戴墨镜,你把他双击就可以打开,打开以后效果就是这样的,他是一个森林,包括 脆很多的脆,还有什么呀?呃,特瑞地形,包括太阳光,还包括一个开门网,但是那个开门网我们要把它删掉,你比如说我先给他添进去,复原他原来那个样子 啊,他原先这样有一个开幕点,有一个主的摄像机,但是如果我们想要用到那个第三人称视角,那个摄像机就是视角跟随我们第三人称那个操作的机器人的话,你需要把他这里面的主摄像机先给删掉,然后 在这个兔子里面有我们的 status 的一个新增的一个菜单,哎,这三项分别是 reinstore, dependence, 我们当时装上的第三人称呃角色控制器,它里面还需要 有一些其他的附带的一些那个基础包,比如说是新内莫逊这个摄像机包,还有一些其他的。那如果你要当时装的时候,他这些底喷 nos 包,也就是依赖包没有装好的话, 这第一项就是瑞 install 底喷 densis, 就是重新安装这一些我们当前需要的依赖包,我这装好了,你就不需要管他了。第二个是瑞塞特斯尔坡斯斯达特 m 圈, 这是就是我们现在要用到的把这个第三人称控制器,包括他里面那些呃角色了,包括他那个摄像机了,包括他所有用到的东西都添加进来。这三个游戏对象,开门吧,这两个都是 是开幕式相关的。还有一个就是 plarrmocherplarrmochur, 就是我们要用到的这个什么呀角色的一个控角色了,就是他的机器人,机器人本身, 那我们为了避免操作的时候出失误,我们可以把这个给他分成两个不同的模块, 先新建一个空的给猫不见他,给他命名为就叫头儿人吧,或者叫以外门他或者叫 level 来吧,然后重置啊,他这已经重置过了,然后把我们除了这三个以外的其他的给他拖进来,就是环境都扔 到这个 level 里面,在新建一个空的,看一下他的菩提性什么,这都是没有问题的,都是出水的,哎。给他叫 player, 然后把我们 第三人称,视角控制器这些新生成的三个游戏对象给他扔到这里面,然后来我们就暂时给他 点上这个手指,就不让他那个禁止触碰了,禁止勿碰到,我们再操作的话就没什么问题了。这些都添加进来以后,其实就已经完成了,我们直接点击运行就可以操作我们这个游戏角色,让他在我们这环境里面游走了, 哎,整个过程实际就这么简单, 光影效果,声音都是现成的。 好,我们进一步的再来看一下这个项目, fantastic forest environment free example, 这就是我们这个后面导入的这个场景环境, 也就是草地树之类的这个包他加载出来的这些内容。而撒弹 ss 是我们主要的核心的 三 d 的决策控制器,它相关加载的这些资料在这个根部路底下有一个什么呢? pdf 说明文档,把它打 打开,它实际上里面包含了一些进阶的操作,大家可以自行去学习一下,它里面包括那个 s 链接也有。 他不光是支持我们 windows 进行操作,就鼠标键盘操作,他因为使用的是新版的这种音铺的 system, 他还支持快速的切换到这种手柄和触屏,手柄就是游戏主机,触屏就是手机 平板都是支持的,在这里面讲如何来操作,如何来调整,我们想要使用它自带的就是斯德 plus and ctrl。 二、自带的一个测试的一个场景的话,是在 statusstops and ctrl, 然后 sins 底下有一个 playground 的信,把它双击打开。好,我们前面的 ceo 一下,哎,这个里面就是他自带的一个相当于白膜测试环境, 点击 shift 是 red, 左边 shift 加上这个方向键是 red 空格跳 重力系统什么的都做的非常好,包括声音。 你想要在这个里面测试一些,有些同学不是说想要做那个第三人称视角的那种射击游戏或者公 游戏,你前期就可以借助这个包快速的来进行测试啊。还有一些同学想要快速的构建一些那种项目,比如说毕业设计或者说期末大作业的话,借助这个东西也是非常方便的。 关于这个第三人称视角控制相关的一些具体细节,我们暂时不去多说,你包括这里面的每个参数的配置,他包含的有这个 啊, cinematon 包含的有这个新版本的 input system, 也就是控制输入,控制那一套系统,我们到时候把这个输入新的那种 input system 和 cinematon 这一套东西都给大家 说完以后,按部就班讲完以后再来把这个第三人称控制器给拆解一下,从零给大家还原一下 啊,但是他前提需要一些,呃,扩展基础知识不说扩展知识有些那种底喷能 cs, 咱们这知识也有那个前置的一些知识,要把那一块都先讲完了,才能很详细的给大家拆开。 所以这一次咱们先讲一下如何快速的把这个第三人称里面 机器人角色给他替换掉,替换成咱们自己做的模型,然后可以让大家快速的来完成一个那种预定的第三人称项目,或者说快速的进行一个你的场景测试等等的。 那怎么来做呢?首先我们把这个需要的素材给下了,我还是使用当初给大家讲这个动画导入导出的时候用到这个小蜘蛛人吧, 哎,小蜘蛛玩他本身这个模型是从一个三 d 网站上下来的,是这个文件 他虽然说是已经瑞给的了,但是他还不能够直接在我们这里面用他这个, 嗯,应该算是骨骼绑定,不太符合我们当前这里面的需求,所以最好的是你重新绑定一次,最好最简单的方式就是把这个三 d 模型从三 d 模型网站,当时那个是 把这个模型从这个 scatch five 网站上下下来以后,然后上传到 mixamo 上面,让 mixamo 自动的给我们进行一个骨骼的绑定, mixamo 进行这种骨骼绑定,再下下来我们就可以直接用了,你就不需要在那个设计器编辑器里面一点一点的给它绑定骨骼了,非常方便。那我来操作一下吧。先 ablot, ablot character, 那斯莱克特,凯克特 fell, 我们把这个解压出来,只需要上传 sous 里面的 fbx, 因为他其他的也用不上,是吧? texture 他有自动不会在这个 mixam 上面给你绑,你需要把这个 tax 线到时候放到 young 体里面就行了。 他有一个处理过程,这个实际上就是上传加那个绑定骨骼的这个过程,创建他里面的这种骨骼系统,这就是处理好之后的,你看他明显是有一个这种前后观望的一个爱豆状态,这明显就是已经骨骼绑定好了点。 next, 其实这里面预览的时候你就可以下载了,当烙的,我们这选中 ibx for youtube, 然后 pose 的话就 tpose 就可以。当烙的 好,下载完以后我们把它倒进去。 这块的话,暂时 先不管他导入,我专门在新建一个文件加就叫 specimen 吧,然后双击右键 饮泡腾牛 s 一个是这个 tex 圈,肯定全都需要,要不然的话是没有那个表皮的,我们先把 tax 圈扔到这里面,然后再导入导入我们刚才下载好的那个 谷歌绑定,你看你要先把他才放,放进来的话他直接就把这个皮就自动给你蒙上去了, 他在同一个文件夹自动就会找到了。如果你要是先没有这个胎线,先倒进来的是那个模型的话,他模型还是一个白模,那我们直接就可以把它拖进来。哎,可以用,我们暂时先不拖 我们。嗯,直接就把它绑绑住得了,但里面需要先更改了一点啊。 moderate, animation, material, 我们只需要动瑞格,瑞格把他的爱美信太普换成给我们拿的,然后 opla 别的暂时都不需要动, 别的都不需要动。然后这一块操作比较重要啊,选中我们的 pla r m 曲 点右键,在 profile 里面把它安排的 complete, 我们需要把它里面的这个机器人给他替换, 替换的话他本人这个不是 fab, 是一个浴室架,浴室架的话你没法动,你要一动的话,所有东西是不是都全动了?所以说我们先把它解绑,就是说当前这个游戏对象 和我们玉之剑解绑,保留他那个玉之剑里面所有东西,但是和玉之剑没有任何关联了,现在这就是玉之剑安排他的一个过程,这以前我们说过,然后点开他在 geometry 里面把这个 mch max, 就是把它本身这个模型给删掉, 然后把我们这个新的模型拖进来就行了,拖到这个我们吹底下,你看还有吧? 但他这个比较大,他当时设置的时候,我估计他用那个变音器可能是三 d max 吧, 他这种建模的时候的比例和我们用题里面不太一样,那你就根据自己的经验给他 skill, 你比如说我全部都给他射成零点五, 零点五,如果不够的话,零点五,零点五差不多了吧,零点五可能稍微有点低,零点七 啊,这样差不多,那你如果要是怕不太一样的话,你可以再把刚才那个模型放上,比对着来进行一个缩放,要等比缩放啊,缩放好以后 到这个 pla rm 圈上面把他的 avata 换一下,点开这个对象选择器,我们要把它换成这个 spatterman 上面这个他的 avata, 然后运行看一下 效果啊,是不是又可以了? 哎,这就是快速的把自己的模型替换到这个三 d 的第三人称视角的控制器上,它里面其实包含了挺多东西的,可以快速的让我们完成自己项目的初始搭建。




here's the idea i'm gonna spend a couple days and try to make a little three d rpg game like breath of the wild or dragon age, and i'll be implementing it one hundred percent from scratch okay, so i'm allowed to steal my own code if i already wrote it so i'm totally just going to copy paste the setup code from a previous tutorial and that gives us a basic plane and skybox nothing special now a lot of game engines unity included use an entity component style architecture which really lends itself well to reuse i like working with this style but of course since we're working in javascript we have nothing so let's make one how hard can it be right i'm just gonna crap out a quick one it'll be a pure component based system as opposed to the newer entity component systems, but in reality there's not much api surface these things an entity is a glorified array of components with some accessors and management functions and that's it and once we have one the first thing we want to do is make a player controller and third person camera luckily again i can just deal for myself again we already made these in a previous tutorial these are getting a quick copy paste right into their own components so i just need to dump in the player controller code and wrap it all up into this player basic controller component and that gives us a fully working walking character same thing with the camera we covered that previously in third person cameras and so again i'll just copy paste this shamelessly into the project calling a third person camera the gist of the code is that you're tracking a spot just ahead of the character smoothly interpolating the camera each frame towards the ideal spot once, we have an entity in the world set up with this component you've got a walking character with the camera trailing behind them an rpg with no weapons would be boring though so let's get a sword into this guy's hands of course we'll be doing this as a component because then we get to swap out other weapons and all that jazz, so we're declaring an equipped weapon component and the goal here is just to load the specified weapon and then root it to the model's hand in the skeleton things rarely work on the first try, so i ended up working through a few problems, but eventually we got this guy running around with a sword in his hand getting an attack animation is the natural progression here and luckily we already had made a dance state in the finite state machine, so this is mostly going to be a search and replace job a few quick renames later and we have an attack state and i can swing the sword around i decided the next thing to do is to jazz up the world a bit had some trees and stuff so obviously make the world a whole lot bigger first okay that looks good, i also don't want to pay actual money for this luckily, i know people post free stuff in the game dev subreddit all the time so i can just search there i looked at a few posts and this guy quaternious has some cool looking stuff i should be able to come back here for a bunch of assets anyway, we need some foliage and stuff so i took this nature pack now for the code normally, i'd make some sort of render component that's reusable but that requires planning so i'm just gonna copy paste the code and create a standalone static model component future simon will have to clean this up then you spawn a bunch in the world at random spots and voila you have the exact same tree stamped out a whole bunch of times that nature pack didn't just come with birch trees so so i'll just pick a few more of these at random then we just need to write some quick code to randomly pick from a few of the ones we chose and now we've got like a forest or something the code is pretty bad but luckily we didn't spawn a tree right over our standing spot there's also some really nice low poly clouds on the site so let's go with those this is just a straight up copy paste of the loop that spawns trees, but we'll spawn these nice and high and that gives us well, they're kind of hard to see actually white on white wasn't the best color choice on my part my bad let's add a sky i've done complete realistic sky scattering simulations before but let's do this the lazy way three js has an example with a super simple and decent luke and sky so i'm just going to lift that directly into our project basically it's just a skysphere and it blends with the fog near the horizon so in the distance you get a blending between the fog and the sky color that's all good we have the sky in let's move on to inventories a lot of rpg style games have something like a backpack where you can manage items you pick up and stuff i'd like to do the same thing here pop up a menu with a grid of items and let you drag stuff around since this is javascript and the web i'll just code this up using html i just need to get a button down in the bottom center of the screen i kind of hate html so i'm mostly used divs and flexbox for everything you have been warned this is not best practices i ended up with a black button it's a bit plain so i checked out game icons and there's a ton of really neat icons on there i nabbed a quick backpack icon and stuck it into the game if i have time i'll go back and color it and make it look nicer now to make the actual ui i fired up gimp to get a good character shot of the model i'm using then it's off to write some incredibly bad html this is just the azillion divs laid out in a grid and give him some ids so i can refer to them from the code later but it looks good now we need some actual logic for this thing i created a quick ui controller component and dumped some logic in there for opening and closing the menu and created a ui entity in the main file now it opens and closes like we want, but we want actual stuff to hoard so we create a new inventory controller and inventory item components inventory item is mostly just to hold information about a specific item in the inventory an inventory controller handles the logic of choosing a slot updating the ui with the icon that kind of thing just bookkeeping really then of course we define a few items in the world and give them to the player and as you can see these items now show up in the inventory also, i help myself to a few more icons from game icons next i want to make it so you can drag them around that's pretty easy to do in html at least i've heard i have no idea how to actually do it, but the tutorials don't look that hard i just seemed to need to add this draggable property to a lot of the elements that i want to drag and then in the inventory controller, i'm supposed to just need to go and set the on drag and on drop event handlers and that should let me move things around in the inventory i got it going after a few tries there were all screw ups in my logic for swapping the items now let's make some stats because the g's love having character stats i'll make it pretty simple, we'll pop up a menu here and we'll just list out all of the stats on the left and their values on the right and of course we'll have to add both the htmo code followed by some sort of health component there will update the ui and finally back to game icons to help myself to a nice stats icon looking good we have stats now i kind of want to add some small details like tool tips and again since this is html it's not supposed to be super hard i looked up a few tutorials added some quick tips and junk to my html code and pretty soon i had a little floating tooltip and of course once that was done i added full descriptions for all the different stats these are all complete nonsense except for strength i actually use that to do a bit of damage calculation the rest are just gibberished now okay, let's get moving a bit more and try to add some more enemies as i mentioned before i don't want to spend any money on this so i'm going to go back to quaternius for some more free model goodness there's a monster pack here so let's grab it in the code i need to define a new component for the mpc that will eventually house the ai and logic so i'm just gonna go with npc controller for now, and this is going to be a shameless copy paste of the player controller component with some modifications to change the finite state machine and customize it a bit for generic npcs of course you also need to add an entity in maine, so i just did that quickly there we go the ghost is there now just kind of sitting there doing nothing so let's go back and add some primitive ai just to get it to chase us an attack this is going to be insanely simple because the player can already move into attack so the plant here is just to use that exact same code, but the ai will be pressing the keyboard buttons instead simple huh and to find out what's close by we'll just use the spatial grid that we coated up a few weeks ago so we just drop it into a component and off we go this was supposed to be pretty simple and i'd like to say this worked on the first try, but i screwed this up pretty badly i ended up spending more time on this than i would have liked but eventually i got it working though so yay but they just swing at each other this is kind of boring let's make them hurt each other what i need to do is make an attack controller component and its job is really simple it watches the attack animation and looks for a specific time in the animation and then send some damage all right so now i can take a few swings and i can totally kill the ghost and that also means that the ghost can kill me eventually, i didn't make it very strong one problem is that it's hard to tell what's happening though it would be nice if we had some ui in the corner, a lot of games draw a little picture of the guy or maybe have some health bars or whatever, so i'll just quickly draw one myself using the character's image, and will make it host a health bar then some basic html just to position the image in the top left corner of the screen and we of course need to hook up the health component so that it updates the ui awesome now we can watch the ghost murder me in real time, but i also want to see how much health the ghost has a lot of games do something like this where they float a little health bar above the enemy's head this should be pretty simple conceptually it's just a quad that floats over the enemy's position and displays their health somehow like maybe green to red as it goes down and shrinking the bar or blacking out part of it or whatever it took a little bit of iteration had to work through getting it to face me getting it look roughly right animating it a bit so the health bar kind of smoothly drops down but eventually it didn't look so terrible with that out of the way the next goal is to add a leveling up system and i'm not going to overthink this too much what i basically need is to accumulate experience points and then play a small effect i already made a particle system in a previous video, so let's just dump that right into the game as a component i'll make two components now one is the level up spawner whose job is to make these level up entities and the other is the actual level up effect itself that gets spawned once those are hooked up you can watch the staff go up as i kill this guy also the effect goes off, so we get some stars and stuff okay, so it's the last thing to do to make this more rpg ish, we need quests you always have a zillion quest to do in any rpg game so we got to add this back to miximo to help myself to another free model i just want someone to stand around and deliver some quest lines so pretty much anybody will do as long as they fit in with the general fantasy theme of course, i just declared another entity in the world with the new model and plopped her right down beside my spawn point can't really do anything but she's there at least i want to make it so that when you click on her she delivers some lines and adds them to your question and this should be really easy since three gs has this ray caster class all i have to do is integrate it into the game and it doesn't seem to be working i just wanted it to print a small message to the console, but nothing is happening as it turns out this class doesn't work with skin meshes so let's write it ourselves instead of using the ray caster and all the meshes i'll just go ahead and find all of the pickable objects nearby and then i'll make collision boxes out of all of them after that i can do ray boxed collision detection to see which one i clicked on it's not gonna be even close to perfect but at least it should work now when i load the world up, i can walk up to the mpc and click on her and it works like i expected good enough, so i'll declare job done okay let's get some quest ui up on the screen next so if i click on the npc, it'll bring up some sort of dialogue describing the quest so i just wrote some quick html to put dialog box in the middle of the screen of course, you actually need a quest of some sort so let's make a quest component and i'll hard code the first quest in here the job of this component is to get notified when the npc is picked and then show the quest dialog adding the title and body of the quest text and of course i'll have to write a quick quest description so that it shows up in the game now that's hooked up i have this little quest journal thing that can bring up it's empty now, but now i can go click on the npc when i do that she shows some quest description stuff and the quest now shows up in my quest log, so i can review the quest if i need to this is pretty cool most of the basic elements of an rpg are in place let's go and add some more monsters to the world since we already had monsters before all doing here is making a big loop or else one like a hundred more that quaternius package i downloaded came with like two dozen different monsters so i'm just going to select a few more of them and randomly choose between them i'll also randomly scatter them throughout the world so they don't just swarm me and kill me right away and there we go there's a whole bunch of monsters all over and i can run around and kill them it would be cool that i gave them loot or something maybe i'll revisit this and have it so that you can go and loot the corpse looking for stuff also yeah there's still a lot of bugs to work out anyway, that's as far as i got before i kind of ran at a time with a bit more work this could maybe be half decent some height map terrain, some hand placed npcs and towns and shops and stuff could look good, i'll clean the code up and throw it up on github so look for it there if you decide to use this to make something like your own project, i'd love to see what you end up making until next time cheers。

欢迎大家跟我一起在哔哩哔哩课堂学习 unit 游戏开发,这次为大家准备了适合快速入门学习的教程内容,一起来看看吧! 我们会制作一款休闲手机游戏,就是那种玩起来停不下来的。我们会通过这个项目学习 unit 编辑器以及 cia 不编程语言教程,使用最新的 unit 二零二二点一版本,帮助你快速上手新功能。 同时这个项目也会教大家如何接入 uni 体的广告系统,实现免费休闲游戏,获得广告收益。 教程会教会大家构建一个游戏的基本知识,例如 俯视角渲染、全新的输入系统、动画控制器、音乐与音效 unit ui。 同时,在 csa 方面,我们也会学习非常多的代码 api 知识,我会带你写每一行代码,并讲解他的意思。 也会教大家如何使用代码手册来学习新知识,让你学会自学的方法。完成这个教程,你将得到一个真实的手机游戏。还在等什么?赶快来做个游戏分享给你的朋友吧! 如果你对游戏开发很感兴趣,有一定的逻辑思维,即便你对编程语言完全不了解,也可以通过这个教程快 快速上手制作游戏。如果你已经对 unit 有些了解,那么你仍然可以从这个教程中学习很多新知识和小技巧,赶快加入吧,我在哔哩哔哩课堂等着你!

阿瑞阿瑞,我刀光坐地上火星怎么办怎么办?这个是这位粉丝才给到我的时候的一个版本啊,再来看一下咱们修改过后的一个感觉,哇,好帅啊! 哈喽,大家好,今天呢还是帮一位粉丝小老弟改一下他的刀光作品。嗯,他现在的反馈是他不会做刀光,然后也是一个初学者,学的时间不是很久,所以说咱们做的时候也要做到一个他能接受到的一个范围, 就是说他能吸收到知识点的一个效果。来,咱们先看一下, 首先就是节奏太平,然后这个刀光这个缩放就别要了,很难看的,不跟刀,刀都挥到这了刀光才出现不太对, 然后就是整体刀光没有拉开,就是我看不出他的节奏,他没有快慢,也没有出现的快慢,就感觉他很平很柔,但是里面的纹理感还是能看出来的,这点还不错。 外面这一层是个什么东西啊?可以不要,可以去掉,就他不合理,包括这些烟雾,这些烟雾现在是用的很卡通的序列图,连最基础的一个包裹感都没有做,就是你的烟雾要么就是地面,要么就是跟刀, 这不太好。爆点的话也是现在没有节奏,就是突然就给了一个放大,然后小粒子也是小粒子用的透明效是最好 是用缩小啊,因为这种小粒子用透明消失是很难看的啊,你看这个刀光很脏,他的头部居然是黑的,就代表你的暗色成绩已经超越了你的亮色成绩。 然后没有一个很锋利的感觉,就是刀工的整体感觉没有做出来,现在的话更像是划了一个剑气,就是气流的一个感受,包括溶解的也很碎,现在溶解的太碎了就不好看 哦,还有一个就是现在东西太大了,这一种很大的效果啊,可能在几年前的那一种手游啊,或者是什么上面比较常见,现在的话还是比较偏向于跟刀,或者比 刀大一点,宽一点点。对,那咱们就开始今天的一个优化吧。 行,咱们今天的刀光就改到这老规矩,咱们还是先看一下咱们没有修改之前的。 ok, 来看一下,这个是这位粉丝才给到我的时候的一个版本,实际上之前讲的一些问题都是存 在的,不过这个小栗子做的还挺不错的,居然在这个死亡的一个视角这下面还让我能感觉他在冲刺,挺好的。 还有些刀光的一些配色呀,包括一些刚刚爆点的节奏问题,刚刚都说到了,然后再来看一下咱们修改过后的一个感觉。 嘿,那行,今天的改作业环节就到这,然后我建议的是我一会把原文件发给你去下一个 unit, 二零二零点三点二 e f 一,然后原文件你可以放在 放在这个版本里面去对着复刻,尽量不要直接拿来用,因为我还是希望你你是去学习做法,就是一些东西的一些做法,比如刀光的做法呀,然后自己去画画贴图。 ok, 想和我一起学习游戏特效的小伙伴们可以点个关注加粉丝群,咱们一起交流学习。