Unity 武器拖尾效果
CSDN资源地址:http://download.csdn.net/detail/akof1314/7610241
因为这个插件提供的AnimationController.cs仅对Animation动画进行支持,对Animator动画支持的话须要自己实现。
文档上说明实现的方式:
- The WeaponTrail can be built by calling Itterate(float itterateTime) and UpdateTrail(float currentTime, float deltaTime). These functions
are called by AnimationController, however if you don't want to use AnimationController you can call these yourself.
以下使用另外的角色模型进行測试拖尾效果。
測试角色的模型包:https://www.assetstore.unity3d.com/en/#!/content/15103
CSDN资源地址:http://download.csdn.net/detail/akof1314/7610385
首先。在Animator窗体,创建休闲idle状态和攻击attack状态。设置它们对应的Motion,设置从idle到attack的动画參数为Attack,类型为Trigger。例如以下图所看到的:
Speed属性能够控制当前状态动作的速度。接着,创建个脚本TestMyTrail.cs附加到角色上,脚本代码例如以下:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
using UnityEngine;
using System.Collections; public class TestMyTrail : MonoBehaviour { private Animator animator; void Start () { animator = GetComponent<Animator>(); } void OnGUI() { , , , ), "攻击")) { animator.SetTrigger("Attack"); } } } |
查看模型,能够看到武器是绑在右手上的,例如以下图所看到的:
给武器(Object003)加入一个子对象,命名为Trail,为其加入WeaponTrail.cs脚本、Mesh Renderer组件。材质为Pocket
RPG Trails提供的材质,设置好例如以下图所看到的:
改动TestMyTrail.cs代码为例如以下:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
using UnityEngine;
using System.Collections; public class TestMyTrail : MonoBehaviour { public WeaponTrail myTrail; private Animator animator; .033f; ; .003f; void Start () { animator = GetComponent<Animator>(); } void LateUpdate() { t = Mathf.Clamp(Time.deltaTime, , .066f); ) { while (tempT < t) { tempT += animationIncrement; ) { myTrail.Itterate(Time.time - t + tempT); } else { myTrail.ClearTrail(); } } tempT -= t; ) { myTrail.UpdateTrail(Time.time, t); } } } void OnGUI() { , , , ), "攻击")) { animator.SetTrigger("Attack"); } } } |
如今执行,能够看到休闲状态时。武器拖尾的若隐若现,例如以下图所看到的:
攻击时的效果:
要调整好Trail对象的位置、旋转等,尽量贴合武器,设置拖尾的高度,尽量与武器同长度。才干产生较好的效果。
当攻击结束,武器往回收的时候。也会有拖尾,例如以下图所看到的:
假设要去掉这个时候的拖尾,能够採用更精确的控制拖尾的出现。选中攻击动作。切换到"Animations"。播放动作,在攻击開始时刻,加入一个事件,例如以下图所看到的:
在攻击完成,也加入一个事件。例如以下图所看到的:
|
1
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
void Start ()
{ animator = GetComponent<Animator>(); // 默认没有拖尾效果 myTrail.SetTime(.0f, .0f, .0f); } public void heroAttack() { //设置拖尾时长 myTrail.SetTime(.0f, .0f, .0f); //開始进行拖尾 myTrail.StartTrail(.5f, .4f); } public void heroIdle() { //清除拖尾 myTrail.ClearTrail(); } |
如今执行,就会发现休闲状态时候,不会有拖尾效果。当进行攻击时。拖尾仅仅在对应的时间点进行出现。例如以下图所看到的:
武器回收的时候,也不会有拖尾了。例如以下图所看到的:
1.Unity3D 武器拖尾效果(刀光) 使用PocketRPG Trails http://blog.csdn.net/xv_ly15/article/details/8509781
2.Unity3D研究院之挥动武器产生的剑痕特效(四十七) http://www.xuanyusong.com/archives/2110
Unity 武器拖尾效果的更多相关文章
- [Unity3d]向量的过度方法以及拖尾效果
Vector3.RotateTowards() 用法 public static function RotateTowards(current: Vector3, target: Vector3, m ...
- [Cocos2d-x For WP8]MotionStreak拖尾效果
拖尾效果是指在在游戏中,一个精灵在运动的过程中会留下一个短暂的轨迹效果,在游戏里面如打斗的特效往往会需要用到这种效果来给运动的增加绚丽的效果.那么在Cocos2D-x里面我们可以使用一种内置的拖动渐隐 ...
- cocos2d-x 2.0 拖尾效果分析
转自:http://game.dapps.net/gamedev/game-engine/7281.html 在Cocos2d-x中,拖尾效果有一个专门的类CCMotionStreak来实现.下面我们 ...
- 【转】Cocos2d-x 2.0 拖尾效果深入分析
Cocos2d-x 2.0 拖尾效果深入分析 另:本章所用Cocos2d-x版本为: cocos2d-2.0-x-2.0.2@ Aug 30 2012 http://cn.cocos2d-x.org/ ...
- cocos2dx 以子弹飞行为例解说拖尾效果类CCMotionStreak
在游戏开发中,有时会须要在某个游戏对象上的运动轨迹上实现渐隐效果.比方子弹的运动轨迹,假设不借助引擎的帮助,这样的效果则须要通过大量的图片来实现.而Cocos2D-x的拖动渐隐效果类CCMotionS ...
- 浅谈canvas中的拖尾效果
引言 很早就想了解以下 canvas 中的拖尾效果(如彗星,烟花等效果)是怎么实现的,但是一直没有深入了解,正巧在 codepen 上看到一个 demo,代码简单,效果炫酷,故有此文. 什么黑科技 在 ...
- Cocos Creator 的实现拖尾效果
在游戏中,有时会需要在某个游戏对象上加上移动后的轨迹若隐若现的效果.使得游戏的效果较好,比如游戏大招,刀光,法术,流星划痕之类. Cocos Creator提供了一种内置的拖尾渐隐效果的实现方法:组件 ...
- Unity3D-飞机拖尾效果
1.插件准备 unity3d官网,Assert Store搜索Cartoon_airplane 插件 2.拖尾效果实现 飞机显示 拖尾组件设计 在airplane_02下 右键 Effects-Tra ...
- 如何用纯 CSS 创作一个慧星拖尾效果的 loader 动画
效果预览 在线演示 按下右侧的"点击预览"按钮可以在当前页面预览,点击链接可以全屏预览. https://codepen.io/comehope/pen/YLRLaM 可交互视频教 ...
随机推荐
- oracle 12C SYS,SYSTEM用户的密码都忘记或是丢失
密码 conn / as sysdba alter user system identified by Abcd1234; manual script first -->manual_scrip ...
- 设计模式——浅复制VS深复制
背景 在学习原型模式的时候,採用了一个差别与其它模式的新方法.採用了"克隆(Clone)方法.通过实现ICloneable接口中的Clone()方法来达到克隆的目的. 代码实现过程中,存在了 ...
- 使用Maven整合SSH总结
本人自己进行的SSH整合,中间遇到不少问题,特此做些总结,仅供参考. 项目环境: struts-2.3.31 + spring-4.3.7 + hibernate-4.2.21 + maven-3.3 ...
- Sql视图创建语句及修改视图
create view [dbo].[AllUsers] as select u.UserId, u.Firstname, u.Lastname, u.ts, am.Email, au.UserNam ...
- 【已解决】 iView-admin 动态路由问题
IView-admin 在使用的时候 跳转客户详细后,点击其它页面,然后再从选项卡进入页面时,发下控制台 报错,不能正常打开客户详细页面 [vue-router] Route with name 'c ...
- 图解WinHex使用入门
一 Winhex和相关概念简单介绍 1 Winhex 是在Windows下执行的十六进制编辑软件,此软件功能很强大,有完好的分区管理功能和文件管理功能.能自己主动分析分区链和文件簇链.能对硬盘进行不同 ...
- hdu 1398 Square Coins 分钱币问题
Square Coins Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- 安卓手机的后门控制工具SPADE
SPADE,一款安卓手机的后门控制工具,安全研究人员可以以此了解和研究安卓后门原理. 首先,我们从网站www.apk4fun.com下载apk文件,如ccleaner.然后,我们安装spade git ...
- Hdu 5288 OO’s Sequence 2015多小联赛A题
OO's Sequence Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 131072/131072 K (Java/Others) ...
- Http和Socket 优劣比较 使用场景选择_转
转自:http://www.cnblogs.com/webwlsong/p/3198712.html 了解HTTP和Socket之前先对网络7层协议有个了解: 7 应用层6 表示层5 会话层 4 传输 ...