你好，欢迎回来 hello and welcome back
这堂课的目的是产生一个 the purpose of this lecture is to produce a
落叶粒子效应 fallen leaves particle effect
当橡树被砍倒的时候 when the oak tree is being chopped down
所以我给你一个简单的演示 so I'll just give you a quick demo
我们将要实现的目标 of what we're going to achieve
在这次讲座中 in this lecture
所以我就去玩了 so I'll just go and hit play
我们就抓住脚趾 and we'll just grab the toes
我们就在上面收集一个鸡蛋 and we'll just collect an egg on
只是 and just
在这里挖个洞 dig a hole here
然后我们把蛋种在 and then we'll plant the egg on
按g键 press the g key
使橡树充分生长 to fully grow the oak tree
按20次 to press it 20 times
然后我们选择斧头 and then we'll select the axe
然后我们会 and then we'll
撞到树上，注意 hit the tree and notice the
树叶的粒子效应 particle effect now of the leaves
当我们砍树的时候 as we chop down the tree
可以 okay
这就是我们在这堂课要做的 so that's what we're going to be doing in this lecture
所以我期待着在那里见到你 so I look forward to seeing you there
你好，欢迎回来 hello and welcome back
如介绍视频中所述 as mentioned in the introduction video
这堂课的目的是 the purpose of this lecture is to produce
落叶粒子效应 a fallen leaves particle effect
当橡树被砍倒的时候 when the oak tree is being chopped down
所以我们要从 so we're going to start off by
为粒子效果创建游戏对象 creating a game object for that particle effect
所以我们就导航到助理场景 so we'll just navigate to the assistant scene
然后我们右键单击 and then we'll right click and then
我们将创建一个空的游戏对象 we'll create an empty game object
我们称之为游戏对象 and we'll call that game object
落叶 deciduous leaves falling
所以这是果汁 so this is juice
树叶 leaves
坠落 falling
我们可以重新设置转换 and we can just reset that transform
我把这个拖过去一点 I'll just drag this across a little bit
只是为了让我们有更多的空间 just so we have a bit more room
以及这个游戏对象 and to this game object
我们要添加一个粒子系统组件 we're going to add a particle system component
所以只要点击我们的组件 so just click on our components
然后搜索粒子系统 then search for particle system
现在我们要做的就是配置这个粒子 and now all we need to do is configure this particle
表示落叶的系统 system to represent falling leaves
所以我要做的第一件事就是 so the first thing I'm going to do is
将“持续时间”更改为1.6 change the duration to 1.6
我要将开始生存期设置为1.6 I'm going to set the start lifetime to 1.6
然后是起动速度 and then the start speed
至0.2 to 0.2
我也要关掉循环 and I'm going to turn off looping as well
所以我们就关掉循环 so we just turn off looping
开始旋转 and the start rotation
我要把它设为 I'm going to set that as a
两个常数之间的随机数 random between two constants
在北纬360度之间 that's going to be between north and 360
然后我要加一个重力修正 and then I'm going to add a gravity modifier
让树叶 so that the leaves give
它们坠落的影响 the effect of their falling
所以我要 so I'm going to
设置为0 2 set that to 0 2
模拟空间将是世界空间 and the simulation space is going to be world space
所以这将是 so this is going to be
发生在世界上 happening in the world
而不是本地的游戏对象 rather than local to the game object
和 and
我要设置发射器的速度来变换 I'm going to set the emitter velocity to transform
所以我们没有刚体 so we don't have a rigid body
我要设置最大通过次数为5次 and I'm going to set the max pass calls to be just 5
我们有五组叶子 so we'll have five groups of leaves
会掉下去的 that are going to be falling
作为粒子效应的一部分 as part of this particle effect
接下来是排放 so moving on to the emission
我们将设定一段时间内的利率仅为5% we're going to set the rate over time to be just five
因为我们要用五个粒子 because we're going to go five particles
然后我们要引爆炸弹 and then we're going to set a burst
我们将拥有所有 and we're going to have all
五个粒子 five particles being
在时间零点设置 sets at time zero
所以他们马上就出发了 so they'll all kick off straight away
所以这就是任务 so that's the mission
对于形状，我们有一个球体 and then for the shape we're going to have a sphere
球体而不是圆的原因是 and the reason for sphere and not circle is
我们会有 we're gonna have
也许你可以拥有这个球体 perhaps the sphere you can have things
被踢开了 being sort of kicked off
在一个圆的中间 in the middle of a circle in effect
因为这是恐惧的一部分 because it's part way through this fear
所以我们要把半径设为 so we're gonna set the radius to
1.3 1.3
我们要把半径厚度设为0.1 we're going to set the radius thickness to 0.1
是的，让我点击这里的场景视图 so yeah let me just click on the scene view here
所以我们可以随时点击播放看看我们有什么 so we can always click play to see what we have
所以这就是我们目前的情况 so this is what we currently have
它使用的只是一种标准 and it's using just the sort of standard
此时模式粒子块 mode particle blocks at the moment
所以下一件事就是在生命周期中设置颜色 so the next thing will set is the color over lifetime
我们想让这些淡入淡出 and we want these fade in
所以我们将选择切换生存期 so we'll select cut over lifetime
然后在渐变编辑器中 and then in the gradient editor
我们在这里再停一站 we'll set another stop to about here
然后我们把这个设定为 and then we'll set this one to be
透明的，所以我们会把它一直转下去 transparent so we'll turn that out for all the way down
所以事情一开始是可见的 so things will start off visible
到最后它们会逐渐消失 and then towards the end they'll gradually fade off
所以我们将在整个生命周期内设置大小 so we'll set size over lifetime
我们就用它的标准曲线 and we'll just use the standard curve that it's
所有的标准直线 all the standard straight line that it sets up for that
我们还将设置终生轮换 and we'll also set up rotation over lifetime as well
我们要这些 and we'll have these
粒子旋转 particles rotating
最多180度 by up to 180 degrees
接下来要做的就是设置一些噪音 and the next thing will do is set some noise
给它们一点湍流 to give these a bit of turbulence
我们将强度设为0.5 and we'll set the strength to 0.5
质量将设置为中等2d and the quality will set to medium 2d
接下来我们要做的是 so the next thing we're going to do here is actually
喝杯雪碧 have a sprite
用来代替标准粒子 be used instead of the sort of standard particle
所以我们要设置一个 so we're going to set a
雪碧纹理 sprite texture
所以我们把这个设为精灵 so we'll set this to sprites
然后 and then
我们需要设置要使用的精灵 we need to set the sprite that we're going to use
如果我们点击这个选择器 so if we click on this selector
我们要用雪碧 we're going to use a sprite
叫峡谷橡树二号 called canyon oak underscore two
所以如果我们寻找峡谷橡树，它就在这里 so if we search for canyon oak and here it is here
基本上是一组三片叶子 it's basically a group of three leaves
所以我们会选择它 so we'll select that
所以这将使用 so that will use
那些精灵 those sprites
作为粒子 as the particles
接下来我们需要做的是设置渲染器 the next thing we need to do is set up the renderer
对于渲染器，我们需要设置材质 and for the renderer we need to set the material
默认为精灵 to be sprites default
所以我们在这里搜索精灵 so we just search here for sprites default
和 and
我们需要在渲染器中设置的其他内容 the other things that we need to set in the renderer
是最小粒径 are the minimum particle size
我们要把它设定为 and we're going to set that to be
0.03 0.03
我们要把最大粒径设为0.05 we're going to set the maximum particle size to be 0.05
我们要设置排序层 and we're going to set the sorting layer
成为实例 to be instances
我们要把一层的顺序定为一层 and we're going to set the order in layer to be one
它似乎比其他东西更重要 as well so it appears over the top of other things
现在你可以看到我们有一个 and now you can see we've got a
这里的落叶效应 leaf falling effect here
从这个球体的中心发射出来 being emitted from the center of this sphere here
所以如果我们点击它你就可以看到 so if we click that you can just see we'd get a random
叶片的产生 generation of leaves
它们慢慢地飘落下来 and they sort of drifts gently down
然后就消失了 and then just fade out
目前看来不错 so that looks good so far
这就是雪碧 so that's the sprite
粒子效果设置 particle effect set up
所以我们要为它创建一个预制件 so we're going to actually create a prefab for this
所以，如果我们只是去资产，然后预制 so if we just go to assets and then prefabs
然后收割 and then crop
然后在“效果”文件夹中 and then in the effects folder
我们已经有一个叫rein的预制房了 we've already got one prefab called rein
为了特殊效果 for a special effect
我要把这个拖过去 I'm just going to drag this one
效果文件夹中 into that effects folder as well
现在我们有了 now we've got it there
我们可以把它从我们的场景中删除 we can delete it out of our scene
所以接下来我们要做的就是 so the next thing we need to do is
对裁剪脚本进行一些更改 make a few changes to the crop script
所以让我们双击裁剪脚本 so let's just double click on the crop scripts
在visualstudio中启动 to start that up in visual studio
然后我们将要设置的裁剪脚本 and then for the crop script we're going to set up
序列化字段 serialized field
对于收割动作效果的变换位置 for a transform position for the harvest action effect
将从触发 to be triggered from
所以我只添加代码 so I'll just add the code
你可以看看 and you can have a look at that
所以我把它加在这里 so I'll just add it here
所以我们有一个开始的工具提示 so we've just got a tool tip of a start
这只是说这应该是从儿童开始的 and that just says this should be populated from child
变换游戏对象 transform game objects
显示收获效果产卵点 showing the harvest effect spawn point
然后我们得到了一个 and then we just got a serialized field of
类型转换 type transform
我们称之为收获效应 and we've called that harvest action effect transform
所以这就是 so that's going to be
收获效应发生的时间点 the point where the harvest effect will happen
然后在这个过程中 and then in the process tall action
下面我们要触发的方法 methods below we want to trigger
这就是收获效应 that's harvest effects
所以我们把它加在这里 so we'll add it here
所以我添加了代码，然后讨论了一遍 so I add the code and then talk through it
所以这是为了查看作物的细节 so what this does is it looks at the crop details
看看他的收获行动效果是否属实 and looks to see if his harvest action effect is true
如果是这样，如果我们有收获行动效应 and if it is so if we have a harvest action effect
它所做的就是把这个叫做 then what it does is it calls this
我们之前设置的事件 event that we set up before
哪个是收获行动效果事件 which is the harvest action effect event
我们在这个位置通过 and we pass in the position
我们想要效果发生的地方 where we want the effect to happen
然后我们把实际的 and then we pass in the actual
我们想要的效果 effect that we want to
运行和效果是在这里对作物的细节 run and the effect is here on the crop details
所以那是个流浪汉 so that's an e bum
所以 so
对这棵树来说，这将是柑橘的落叶效应 for the tree it'll be the citrus leaves falling effect
所以让我们保存那个裁剪脚本 so let's just save that crop script
然后我们就回到团结 then we just head on back to unity
现在我们要做的就是 and now what we're going to do is we're just going to
对文件进行一些更改 make a few changes to the
峡谷橡树预制 canyon oak prefab
所以让我们双击它 so let's just double click on that
我们将添加一个新的子游戏对象 and we're going to add a new child game object
做一个庄稼精灵的孩子这样我们就可以创造空的 to be a child of crop sprites so we'll create empty
这将是叶子的产卵点 and this is going to be the spawn point for the leaves
所以我们称之为树叶繁殖点 so we'll call this leaves spawn point
现在你可以看到它在基地 and at the moment you can see it's at the base
我们希望它 of the tree and we want it to be about
就在树的中央 sort of there in the center of the tree
所以我们要设置y so we're going to set the y
变换到四的位置 position of the transform to four
那只会移动它 and that will just move it
你可能就在那里看到了 you probably just about see it there
把它移到树的顶端 that moves it to the sort of top of the tree
树的顶部中心 the top center of the tree
好吧，这就是繁殖点 okay so that's the spawn point
这样我们就可以离开了 so we can just back out of the
峡谷橡树预制 canyon oak crop tree prefab
然后事实上 and then actually
我们还有一件事要做 there's one more thing that we need to set in the crop
树木预制 tree prefab
现在我们已经设置了繁殖点 so now we've set the spawn points
如果我们去 if we go to the
裁剪脚本所在的预置顶部 top of this prefab where the crop script is located
然后我们需要填充刚刚创建的字段 then we need to populate the field that we just created
哪个是 which is the
收获动作效果转化 harvest action effect transform
所以我们可以拖动最小的繁殖点 so we can literally just drag the least spawn point
进入那个领域 into that field
所以现在crop脚本引用了 so now the crop script has a reference to
游戏对象的变换 the transform for that game object
所以当它实际上是 so when it's actually the initiating
落叶效应 the leaves falling effect
所以现在就这样了，这样我们就可以把预制的东西放回去了 so that's done now so we can just back out that prefab
我们可以控制s来保存场景 and we can control s to save the scene
现在我们需要补充 and now we need to add
对我们泳池经理的另一个影响 another effect to our pool manager
所以我们只需点击池管理器游戏对象 so we'll just click on the pool manager game objects
你可能还记得 you might remember before
我们建立了一个10个收割预制池 we set up a pool of 10 reaping prefabs
现在我们要建一个游泳池 and now we want to set up a pool
为我们落叶飘落 for our deciduous leaves falling
还有特效 special effects as well
所以我们要增加游泳池的大小 so we're going to increase the pool size
两个这样我们就可以再放一个预制板了 to two so we can put another prefab in
至于柑橘叶，我们要五片 and then for the citrus leaves we're going to have five
在游泳池里 of them in the pool
我们可以把它拖进去 and we can just drag in the prefab
到田野里去 into the field there
所以我们现在有 so we've now got
我们可怜的经理身上也有柑橘叶 citrus leaves as well in our poor manager
所以我们可以访问这些 so we can access those
从我们的视觉效果经理 from our visual effects manager
下一个剧本是什么 which is the next script that we have to make
有几个变化 a couple of changes to
所以让我们双击 so let's just double click
在我们的vfx管理器脚本上 on our vfx manager script
我们要补充的第一件事 and the first thing we're going to add
在我们的vfx管理器脚本中 in our vfx manager script is
另一个序列化字段 another serialized field
在落叶李的倒下预制参考 reference in the deciduous lee's fallen prefab
所以我会在这之后再加上 so I'll add that after this
我把它贴在这里 and I'll paste it in here
所以它只是一个序列化字段类型的游戏对象 so it's just a serialized field type game objects
这就是所谓的柑橘李倒下预制 and that's called the citrus lee's fallen prefab
然后我们要把它填入督察室 and then we're going to populate that in the inspector
所以我会省下来然后继续 so I'll just save and then carry on
然后我们只需要向下滚动 then we just need to scroll down
到 to
显示收割动作效果的方法 the method where it displays the harvest action effect
现在呢 and at the moment
在我们测试的switch语句中 in this switch statement where we're testing
应该发挥哪些收获作用 which harvest action effect should be played
我们目前唯一真正测试的是 the only one we're really testing for at the moment is
收获作用效应 the reaping harvest action effect
所以我们需要在那里为 so we need to add another check in there for the
落叶 deciduous leaves falling
效果也一样 effect as well
在这之前我们再加一句 so let's add that before here
非常简单 so fairly straightforward
我们只是在重复以前的做法 we're just duplicating what we did before
而不是测试收获效果 instead of testing for the reaping effect
我们正在测试落叶酒糟的下降效应 we're testing for the deciduous lees falling effects
然后我们就用我们可怜的经理 and then we're just using our poor manager
重用对象 to reuse the object
为柑橘铅下降预制 for the citrus leads falling prefab
我们在有效位置通过 and we pass in the effect position
它被称为影响学校的一部分 it is called as part of the effect school
旋转被设置为恒等式 and the rotation is just set to identity
然后呢 and then it
基本上就是将游戏对象设置为活动的 just basically sets the game object to be active
然后在2秒后关闭 and then it disables it after 2 seconds
所以我们可以把它保存下来 so we can just save that
然后回到团结 and then return back to unity
我们最后要做的就是 and the last thing we need to do is just
加上落叶李的秋天的影响 add the deciduous lee's fall in effect
预制到 prefab to the
vfx管理器中的序列化字段 serialized field in the vfx manager
我们刚加的 that we just added
我也是 so is
现在是空的，这样我们就可以把它拖进去 empty at the moment so we can just drag in that prefab
就这样 just like that
然后我们可以控制s来保存我们的持久场景 and then we can control s to save our persistent scene
我们还可以重新设置课程布局 and we could reset our course layouts as well
那应该是 and that should be
我们需要做的所有改变 all of the changes that we need to make
所以我们现在可以测试我们的游戏了 so we can test our game now
所以我们去按play so let's just go and press play
在游戏中，让我们收集我们的工具 and in the game let's collect our tools
我们去收集一些橡子 and we'll go and collect some acorns
所以我们可以种植它们 so that we can plant them
所以 so
看起来不错，那我们就去拿大麻吧 that looks good so let's just get the ho
找些理由 and take some grounds
我们要种这些橡子 and we'll plant these acorns
然后我们会按 and then we'll press the
测试时间提前的g键 g key for the test time advance
我们需要按20次 we'll need to press it 20 times
直到我们得到一个完全成熟的 until we get a fully grown
橡树 oak tree
好了，现在就拿斧子来测试一下我们的能力 here we go so let's get the axe now and test out our
落叶效应 leaves falling effects
就这样 and there we go
所以我觉得这看起来很有效 so I think that looks really effective
所以打了七下之后，树就满了 so after seven strikes it should fill the tree
树叶 the leaves
它们被制造出来，然后逐渐消失 are produced and then they just gradually fade out
它们会旋转 and they rotate
所以这是一个很好的演示 so this is a really good demonstration of how
特殊效果 particular effects
非常简单的方法甚至可以非常有效 quite simple ones even can be very effective
就这样很好 so that's it excellent
好吧，让我们回到编辑那里 okay so let's just go back to the editor
现在我们来控制 now we'll control
我们得确认一下 s to make sure
所有的东西都保存了，我们会瓦解等级制度 everything's saved and we'll collapse the hierarchy
所以按住alt键 so hold the alt key down
点击这里 click on there
今天的讲座到此为止 and that's it for this lecture
所以谢谢你的关注 so thank you for following along
下次见 and I'll see you in the next one