unity中多个门的开关动画保持独立性
List<Animation> storeAnimation;
public void Awake()
{
storeAnimation = new List<Animation>();
storeAnimation.Clear();
}
private void Update()
{
//1. 获取鼠标点击位置
//创建射线;从摄像机发射一条经过鼠标当前位置的射线
Ray ray = firstCamera.ScreenPointToRay(Input.mousePosition);
//发射射线
RaycastHit hitInfo = new RaycastHit();
if (Physics.Raycast(ray, out hitInfo))
{ if (hitInfo.collider.name == "plantLeftDoor01" || hitInfo.collider.name == "plantLeftDoor02" || hitInfo.collider.name == "plantLeftDoor03" || hitInfo.collider.name == "plantLeftDoor04" || hitInfo.collider.name == "plantLeftDoor05" || hitInfo.collider.name == "plantLeftDoor06" || hitInfo.collider.name == "plantLeftDoor07" || hitInfo.collider.name == "plantLeftDoor08")
{
OpenOrCloseLeftDoor(hitInfo); }
else if (hitInfo.collider.name == "plantRightDoor01" || hitInfo.collider.name == "plantRightDoor02" || hitInfo.collider.name == "plantRightDoor03" || hitInfo.collider.name == "plantRightDoor04" || hitInfo.collider.name == "plantRightDoor05" || hitInfo.collider.name == "plantRightDoor06" || hitInfo.collider.name == "plantRightDoor07" || hitInfo.collider.name == "plantRightDoor08")
{
OpenOrCloseRightDoor(hitInfo);
}
}
}
private void OpenOrCloseLeftDoor(RaycastHit hitInfo)
{
leftAnim = hitInfo.collider.transform.GetComponent<Animation>();
if (!storeAnimation.Contains(leftAnim))//说明第一次点击
{
leftAnim["leftDoor"].speed = ;
leftAnim.Play("leftDoor");
storeAnimation.Add(leftAnim);
}
else
{
leftAnim["leftDoor"].time = leftAnim["leftDoor"].length;
leftAnim["leftDoor"].speed = -;
leftAnim.Play("leftDoor");
storeAnimation.Remove(leftAnim);
}
} private void OpenOrCloseRightDoor(RaycastHit hitInfo)
{
rightAnim = hitInfo.collider.transform.GetComponent<Animation>();
if (!storeAnimation.Contains(rightAnim))//说明第一次点击
{
rightAnim["rightDoor"].speed = ;
rightAnim.Play("rightDoor");
storeAnimation.Add(rightAnim);
}
else
{
rightAnim["rightDoor"].time = rightAnim["rightDoor"].length;
rightAnim["rightDoor"].speed = -;
rightAnim.Play("rightDoor");
storeAnimation.Remove(rightAnim);
}
}
unity中多个门的开关动画保持独立性的更多相关文章
- 关于Unity中新版动画系统的使用
Mecanim动画 1:旧版动画系统只能通过代码来控制动画播放,随着动画种类变多,代码复杂度也会增加,同时动画过渡也需要非常繁琐的代码控制,为了让有经验的动画师开发动画,unity推出了针对人物角色的 ...
- 骨骼动画的原理及在Unity中的使用
制作骨骼动画 我们看看这几步操作后,我们得到了那些数据: 1.每个皮肤顶点的初始世界坐标. 2.每个骨骼关节顶点的初始世界坐标. 3.每个顶点被骨骼顶点的影响信息. 4.骨骼如何移动. 骨骼动画原理 ...
- 如何在unity中使用龙骨动画
龙骨 龙骨是Egret公司的一个用来做动画的软件,本文分享一下如何在Unity2D中使用龙骨导出的2D动画 导出动画 在龙骨中文件->导出,导出动画数据和纹理到Unity的项目中,如果打包了的话 ...
- 关于Unity中旧版动画系统的使用
Unity在5.X以后,有一个旧版的动画系统和新版的动画系统. 新版的动画系统是使用Unity动画编辑器来调的,调动画和控制动画 旧版的动画系统是用其他的第三方软件调好后导出到一个FBX文件里面,就是 ...
- 高速上手Unity中最好的补间动画插件DFTween
出处:http://blog.csdn.net/u010019717 author:孙广东 时间:2015.3.17 23:00 DFTween 是一个在 Unity 游戏引擎中高 ...
- unity中的动画制作方法
Unity中的动画制作方法 1.DOTween DoTween在5.0版本中已经用到了,到官网下载好插件之后,然后通过在项目中导入头using DG.Tweening;即可. 一些常用的API函数 D ...
- 动画重定向技术分析和Unity中的应用
http://www.jianshu.com/p/6e9ba1b9c99e 因为一些手游项目需要使用Unity引擎,但在动画部分需要使用重定向技术来实现动画复用,考虑到有些项目开发人员没有过这方面的经 ...
- 动画重定向技术分析及其在Unity中的应用
前言 笔者新的手游项目使用Unity引擎,动画部分要使用重定向技术来实现动画复用.笔者之前在大公司工作的时候对这块了解比较深入,读过Havok引擎在这部分的实现源码,并基于自己的理解,在公司自研的手游 ...
- Unity中的资源管理
一.AssetBundle 相关 Q1:Unity中的SerializedFile是怎么产生的?请问用Unload(false)可以清除吗?因为读取了Bundle里面的内容后已经赋值给其他物体了.而且 ...
随机推荐
- eclipse上的.properties文件中文编辑显示问题
安装 装Properties Editor插件,方法: Help --> Install New Software -->输入:http://propedit.sourceforge.jp ...
- The dependency `XXX` is not used in any concrete target.
1.在新建项目,引入CocoaPod时,当创建了podfile文件后,执行pod install时报一下错误 2.这是因为 这个第三方不知道用于哪个target,所以必须指定target 解决方案 ...
- 【转载】TCP /IP协议详解
首先,TCP/IP不是一个协议,而是一个协议族的统称. 里面包括了IP协议,IMCP协议,TCP协议,以及http.ftp.pop3协议等等. TCP/IP协议分层 提到协议分层,我们很容易联想到IS ...
- (转)A Recipe for Training Neural Networks
A Recipe for Training Neural Networks Andrej Karpathy blog 2019-04-27 09:37:05 This blog is copied ...
- 从零开始 CentOs 7 搭建论坛BBS Discuz_X3.2
由于公司项目需要一个互动平台,可以发起活动,发消息留言,讨论过后发现这竟然是一个论坛的功能. 于是就不打算耗费功夫开发相关功能,直接另外搭一套BBS算球... 一直觉得搭建BBS不是一件难事,目前有很 ...
- 访问github慢的解决方案
问题描述 打开https://github.com很慢. 解决办法 1.打开文件C:\Windows\System32\drivers\etc\hosts 2.添加如下内容: 151.101.44.2 ...
- 关于查询ios的app更新的历史版本记录
https://www.qimai.cn 推荐七麦数据 可以查询app的各种版本更新内容 由于历史久远忘记了自己app第一次上架的时间 通过这个可以查询
- poi 导入Excle
一,AOP 是什么 Apache POI 提供java 程序对Microsoft Office格式文档的读写功能操作 二,所需要的jar包 三,实现代码 1, 读取Excle 返回Workbook格式 ...
- 二、Python数据类型(一)
一.Python的基本输入与输出语句 (一)输出语句 print() 示例: print('你好,Python') print(4+5) a = 10 print(a) 输出的内容可以是字符串,变量, ...
- JS-NaN的数据类型
NaN 的数据类型:not a number .是数字类型但是不是数字 例: var x = Number('abcd'); //结果是NaN alert( typeof (x) ); //结果是nu ...