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里面的内容后已经赋值给其他物体了.而且 ...
随机推荐
- BIOS备忘录之SPI(fingerprint)设备
Reset和INT信号使用的是GPIO功能,需要显式的使用(INT信号使用了GPIO的int number,RST信号使用了GPIO的absolute number): 问题举例 漏电导致功能异常:在 ...
- Thuwc 2019 & wc 2019 划水记
(此处不应有目录,爆零的过程应该慢慢看) Thuwc 2019 拖着箱子去广二,然后发现可以搬出去住酒店.好,然后箱子白搬了.Joker似乎说住宿体验极差,广二宿舍和林荫宿舍质量不相上下,想想wc时要 ...
- 王之泰201771010131《面向对象程序设计(java)》第十七周学习总结
第一部分:理论知识学习部分 第14章 并发 线程同步 多线程并发运行不确定性问题解决方案:引入线 程同步机制,使得另一线程要使用该方法,就只 能等待. ⚫ 在Java中解决多线程同步问题的方法有两种: ...
- JS(JavaScript)的初了解8(更新中···)
1.函数都有返回值…… 而方法的本质也是函数,所以也有返回值. Document.getElementById() 返回的是获取的标签 getElementsByClassName()和getElem ...
- Lintcode174-Remove Nth Node From End of List-Easy
174. Remove Nth Node From End of List Given a linked list, remove the nth node from the end of list ...
- Cent OS & Windows 双系统自定义引导菜单
系统环境 系统:Windows 10 (64-bit) & Cent OS 7 (64-bit) 引导程序:Grub2 编辑 grub.cfg 为了方便,在终端使用命令 su 输入密码进入超级 ...
- js清除childNodes中的#text(选项卡中会用到获取第一级子元素)
我们一般为了代码整洁代码都会换行,如上面所述. 获取div1节点下的childNodes var div = document.getElementById('div1') var child = d ...
- 【python 3】 集合方法操作汇总
基本数据类型 : set 集合(set)特点 : 无序 不能重复(自动去重) 用 {} 或 set()函数 来表示集合 空集合 : set() 1 name = {"江户部柯南", ...
- Pandas 基础(13) - Crosstab 交叉列表取值
这小节的题目看起来还挺晦涩的, crosstab 是 pandas 的一个函数, 作用还蛮强大的, 一起来看一下吧~~~ 首先还是先引入一个例子文件: import pandas as pd df = ...
- laravel 框架的 csrf
由于 laravel 框架自带 csrf 防护, 也就是通过中间件验证请求的 token, 所以 form 表单必须如下设置才可以正常提交, 否则会 419: <form method=&quo ...