工作交接的空余时间,刚好有空,就有兴趣看了看U3D的武器拖尾功能,没想到有插件。下载地址:
Pocket+RPG+Weapon+Trails.unitypackage
PocketRPG Trails的例子演示效果
左刀挥动
双刀效果
PocketRPG的例子中已经有实现拖尾效果的脚本及说明文档,我只是将自己实际使用时遇到的问题与使用步骤更详细的写下来。
WeaponTrail:
实现拖尾效果的脚本。
参数:
Height:拖尾效果的高度,对应武器的长度
Time:拖尾效果残留事件
Always Up:
Min Distance:
Time Transition Speed:
Desired Time:
Start Color:开始颜色
End Color:结束时颜色
使用(PocketRPG文档的ReadMe中有提及)
1.Calling StartTrail(float timeToTweenTo,
floatfadeInTime) andFadeOut(float fadeTime)will fade in and
fade out the trail respectively.
调用StartTrail和FadeOut函数去实现渐显示和渐消失的效果。时间参数以1秒为一个单位。
2.Calling SetTime(float trailTime, floattimeToTweenTo,
float tweenSpeed)can change the length of the
trailinstantly, giving you a little more control.
调用SetTime函数去改变拖尾长度
3.The WeaponTrail can be built by
callingItterate(float
itterateTime) andUpdateTrail(floatcurrentTime, float
deltaTime). These functions are called
byAnimationController, however if you don't want to use
AnimationController youcan call these yourself.
调用Itterate和Update函数去更新拖尾效果,目前还不明白这两个函数的参数怎样添好,幸运的是,PocketRpg的开发者做了AnimationController脚本去代替我们调用这两个函数使拖尾效果更好。
AnimationController:
控制动作,使拖尾效果更好
参数:
Gather Delta Time Automatic:
使用
1.调用AddTrail函数去添加受影响的WeapontTrail对象。
2.调用PlayAnimation函数去切换动作。
-----------------------------------------------------------------------------------------
应用:
为了有一个不错的效果,还是用到源码包中的拖尾材质
并把这两个主要脚本引用到自己的项目中:
将WeaponTrail添加到武器的对象上。并添加如下组件。如图:
然后将AnimationController组件添加到人物的对象上:
下面就可以写代码测试下啦:
运行看看:
参考:http://blog.youkuaiyun.com/xv_ly15/article/details/8509781