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 可交互视频教 ...
随机推荐
- Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
1.Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'. 原因解析: gradle ...
- cpu、内存、硬盘
grep -c 'model name' /proc/cpuinfo
- 安装Linux centos 时编辑选项
将第上一步选择编辑之后出来的文字修改为:>vmlinuz initrd=initrd.img linux dd quiet 这里注意了:网上很多文章都说这一步改成“>vmlinuz ini ...
- 复习mybatis框架(一)----映射文件
参考博主的文章,尊重原创:https://blog.csdn.net/qq_35246620/article/details/54837618 一.给出映射文件 Mapper.xml 的总结: ① 设 ...
- java比较字符串长度
1.一种:str1.length()>=str.length():这种只比较字符串中的计算字符的数量,不管是中文还是英文 2:另一种:str1.getBytes().length>=str ...
- Quartz.Net - Lesson2: 任务和触发器
Lesson 2: 任务和触发器 本系列文章是官方3.x文档的翻译,原文地址:https://www.quartz-scheduler.net/documentation/quartz-3.x/tut ...
- jquery将form表单序列化常json
var formData = {};$.each(form.serializeArray(),function(i, item){ formData[item.name] = item.value;} ...
- R中导入excel乱码的解决办法
本文操作系统环境为win10,使用Rstdio. 要说明windows下在使用Rstdio的时候,在使用xlsx包,导入excel表乱码的解决办法. 1.我们先安装xlsx包 install.pack ...
- 设计模式之前之UML
UML,让系统可视化,让规格和设计文档化的表现方法.下面来简单介绍一下这个UML.
- saltstack之服务管理
1.启动服务 /srv/salt/service/nfs.sls rpcbind: service.running: - enable: True #开机自动启动 # - enable: False ...