粉丝2234获赞8861

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。

你们知道怎么样在油内黑中导入别人制作好的特效物体吗? 大家好,我是郑大叔,一个在家自学做游戏的奔四大叔,今天呢是我接触游戏制作的第二十八天了,我呢想给钻石计划增加一个在水中的感觉,但是我是个新手,又不会做水,怎么办呢? 都说站在巨人的肩膀上可以看的更远,我觉得在做游戏的时候也是同样的道理, 其实现在呢,网上有很多人分享出来的现实案例,我们完全可以学学别人是怎么做的,或者直接用别人做 不好的东西不就可以了吗? nice, 我在给他的上面找了一个水面特效的案例,是不是挺炫酷的呢?但是这是人家的项目,要怎么样用到我们自己的项目中呢? 这时候隔壁老王跳出来说,直接把项目里面的所有文件都复制过来不就可以了吗? 这样的方法可以,当然是可以了,但是垃圾太多了,很多又不是我们需要的,那有没有更好的办法呢? 答案就是打包导出。就是呢,把我们所需要的物体制作成预支件,然后呢进行导出,那相关的文件就会一起打包, 接着呢,在我们自己的项目中导入这个包,那相关的文件就都会一起导入进来了。觉得跟我们项目的配色不是很搭,那就调整一下, 嗯,完美搞定,嘿嘿,这效果有了,我们打包试试看一下人家的文件跟我们的项目兼容性怎么样, 果然还是发生异常了,那我们先看一下出租的原因是什么呢? 其实呢,不管是写程序也好,做游戏也罢,运行或者打包出错应该都是家常便饭的事情,只要我们冷静去查找对应的资料, 我相信一般都会解决的。那这里呢,就是需要把这个类放到一个特殊文件夹里面,然后我们再重新打包,这一次希望一切顺利。 怎么样,这波澜壮阔的场景,是不是完全有一种身处大海之中的感觉?看到这里,你是不是应该点赞关注啦?其实呢,站在这么多年 我学习了一大堆东西的经验之上,我并不建议在学习阶段过多的去依赖别人的作品,毕竟别人的东西不管用多少次都不会变成我们自己的。 然后话又说回来,学习怎么去用别人的东西,那也是必要的,至于用不用才是我们的选择,你们说对吧? 好了,今天我们就聊到这里,有想法的小伙伴欢迎在评论区发表,我们明天不见不散!


如果你是一名游戏开发者,下面这件事一定会颠覆你的认知。最近,全球最大的游戏开发引擎 unit 三 d 在 gdc 大会上宣布了他的 unitai 技术。这次大会上, unit 发布的宣传片非常有趣,只有文字,没有任何画面。可以看到视频中展示的文字有,比如生成一个女性三 d 角色,生成一片拥有灰暗天空的大型地貌, 增加十二个 npc 等等。这些其实都在暗示 unity ai 拥有的强大三 dai 实力。 你只需要说出想要的游戏画面或者功能, unit ai 就能自动帮你实现。可以想象,有了 ai 的加持,未来游戏中 npt 和你的对话会非常真实。视频最后 unit 也提供了他的内测地址。



各位小伙伴们大家好,今天要给大家聊的就是如何让大家在三分钟之内就做出一个像我现在操作的这样的一个三 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 的第三人称视角的控制器上,它里面其实包含了挺多东西的,可以快速的让我们完成自己项目的初始搭建。