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里面的内容后已经赋值给其他物体了.而且 ...
随机推荐
- 【题解】Luogu P4396 [AHOI2013]作业
原题传送门 最快的解法好像是cdq,但窝只会莫队+线段树/树状数组的做法 题目要我们求1.在区间[l,r]中值域在[a,b]中有多少个数2.在区间[l,r]中值域在[a,b]中有多少个不同数 一眼就看 ...
- rabbitmq 3.7.8基于centos7部署文档
rabbitmq 3.7.8部署文档 安装erlang 安装依赖环境 yum -y install make gcc gcc-c++ kernel-devel m4 ncurses-devel ope ...
- html5 浏览文件
var fileInput = document.getElementById('test-image-file'), info = document.getElementById('test-fil ...
- 解决 “MoveFile”: 类型库“XXX.dll”中的标识符已经是宏;使用“rename”限定符 类型库符号与系统符号冲突问题
今天在VS工程当中引入一个组件,编译的时候出现警告, “MoveFile”: 类型库“XXX.dll”中的标识符已经是宏:使用“rename”限定符.虽然只是一个警告,但看着实在不爽,更重要的是,警告 ...
- 王之泰/王志成《面向对象程序设计(java)》第十一周学习总结
第一部分:理论知识学习部分 第十一章理论知识主要为集合类的介绍,在实验中都有所体现且本周主要复习回顾上周的泛型程序设计 第二部分:实验部分 ——集合 1.实验目的与要求 (1) 掌握Vetor.Sta ...
- EF中防止sql注入
EF作为一个orm框架,本身以及放置了sql的注入,但是如果我们需要执行sql语句的时候了?比如,我们需要查询视图"select * from VM where 条件 = {0}" ...
- No Directionality widget found.错误记录。
import 'package:flutter/material.dart'; void main() => runApp(new Center(child: new Text('Hello, ...
- Latex 经常见到的问题和解决方法
Latex 经常见到的问题和解决方法 2017-04-10 22:05:48 [资源下载]Texlive 2018 下载地址:http://mirror.lzu.edu.cn/CTAN/system ...
- pdfmake导出页眉页脚问题
最近做项目中遇到一个导出pdf的功能,我用的是pdfmake插件 pdf使用参考 https://blog.csdn.net/qq_24380167/article/details/78735642 ...
- iOS权限申请
<!-- 相册 --> <key>NSPhotoLibraryUsageDescription</key> <string>App需要您的同意,才能访问 ...