第14节 breakable actors
147 destructible meshes
a geometry collection is basically a set of static meshes that we get after we fracture a mesh. 几何体集合基本上是我们在断开网格后获得的一组静态网格。
选中要破碎的网格物品,创建集合
可以选择不同的碎裂方式,以及选中已经破碎的碎片再次进行fracture(破碎)
设置enable gravity, simulation physics和damage threadhold后可以播放查看破碎效果
选中物体,按住end之后可以将物体至于地面
物品破碎之后显示颜色不对,取消勾线show bone即可解决
148 field system actor: use field to break destructible
创建一个field system蓝图类
enable cluster有使物品聚集起来的能力,可以取消勾选
149 creating field with weapons: using the weapon to break destructible
可以改为box,capsule在物体破碎之后碎片会旋转,而box这种清空会减轻
createfields的蓝图实现(不在c++中实现,只在c++中声明)
150 breakable actor: create an actors that breaks
创建一个c++的actor类
UGeometryCollection是在GeometryCollectionEngine模块下的,需要在build.cs中手动添加这个模块
以c++为基类生成蓝图类
151 blueprint native event: functions with c++ and blueprint functionality
Even though this class implements the interface, that function is not exposed to blueprint. 即使此类实现了接口,该函数也不会向 Blueprint 公开。
In fact, if we go into hit interface, we can see that it's right here. 事实上,如果我们进入点击界面,我们可以看到它就在这里。
It's not even a U function, it's just a C++ function. 它甚至不是一个 U 函数,而只是一个 C++ 函数。
Now, we could make it a blueprint implementable event, but that means it would only be implemented 现在,我们可以将其设为 Blueprint 可实施事件,但这意味着它只会被实现
in Blueprint and then we wouldn't be able to have our own C++ functionality triggered as a result of ,然后我们就无法触发我们自己的 C++ 功能,因为
this function being called. this 函数。
So how do we get the best of both worlds? 那么我们如何两全其美呢?
Well, to do that, we could make this function a blueprint. 好吧,要做到这一点,我们可以将这个函数作为一个蓝图。
Native event. Native 事件。
A blueprint. 蓝图。
这是c++实现的GetHit函数,使用了BlueprintNativeEvent之后,则纯c++实现名改为GetHit_Implementation
152 breaking sounds : playing sound whem we smash a pot
pot之所以会被武器震碎,是因为weapon类上附带了createfield函数增加了一个field立场,而pot是一个BP_Breakable蓝图类实例,其中它的rest collection是一个geometrycollection类,而这个类可以设置特性遇到field力场或其他力后破碎。
在这里会出现一种情况,武器攻击了其中一个potA,另一个potB被potAde field给连带震碎了,但是只有potA被销毁了,因为是potA与weapon overlap然后被调用了gethit函数销毁。而potB只是被武器上的field震碎(或者被potA的碎片所连带的力所震碎),但weapon并没有与potB发生overlap事件,也就不会调用potB的gethit函数销毁potB,因此需要用函数来检测pot是否完整,不完成就调用销毁函数