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 可交互视频教 ...
随机推荐
- 网页计算器 && 简易网页时钟 && 倒计时时钟
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- ionic准备之angular基础——dom操作相关(6)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- Java除法结果带小数、进一法的实现 Java问题通用解决代码
http://blog.csdn.net/windone0109/article/details/5355379进一法: 即省略的位上只要大于零都要进一位 : 四舍五入法: 即省略的位上小于五都要舍 ...
- spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet
spring异常 java.lang.ClassNotFoundException: org.springframework.web.context.ContextLoaderServlet 情况 ...
- ios 从url字符串中获取图片名字
NSString *str = @"http://pic92.nipic.com/file/20160323/22486259_160209631000_2.jpg"; NSLog ...
- 搭建SSH框架整合Struts2和Spring时,使用@Autowired注解无法自动注入
© 版权声明:本文为博主原创文章,转载请注明出处 1.问题描述: 搭建SSH框架,在进行Struts2和Spring整合时,使用Spring的@Autowired自动注入失败,运行报错java.lan ...
- WAS集群系列(3):集群搭建:步骤1:准备文件
说明:"指示轨迹"为"点选顺序",截图为点击后效果截图 环境 项目点 指标 WAS版本号 7.0 操作系统 Windows 2008 系统位数 64bit 内存 ...
- Python读取文件文件夹并检索
import os import os.path f=open("Shouldlist.txt") ShouldList=[] while 1: line =f.readline( ...
- jquery的eq()
jQuery 遍历 - eq() 方法 jQuery 遍历参考手册 实例 通过为 index 为 2 的 div 添加适当的类,将其变为蓝色: $("body").find(&qu ...
- vim与windows/linux之间的复制粘贴小结
vim与windows/linux之间的复制粘贴小结 用 vim这么久了,始终也不知道怎么在vim中使用系统粘贴板,通常要在网上复制一段代码都是先gedit打开文件,中键粘贴后关闭,然后再用vim打开 ...