zoukankan      html  css  js  c++  java
  • 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 = 1; leftAnim.Play("leftDoor"); storeAnimation.Add(leftAnim); } else { leftAnim["leftDoor"].time = leftAnim["leftDoor"].length; leftAnim["leftDoor"].speed = -1; leftAnim.Play("leftDoor"); storeAnimation.Remove(leftAnim); } } private void OpenOrCloseRightDoor(RaycastHit hitInfo) { rightAnim = hitInfo.collider.transform.GetComponent<Animation>(); if (!storeAnimation.Contains(rightAnim))//说明第一次点击 { rightAnim["rightDoor"].speed = 1; rightAnim.Play("rightDoor"); storeAnimation.Add(rightAnim); } else { rightAnim["rightDoor"].time = rightAnim["rightDoor"].length; rightAnim["rightDoor"].speed = -1; rightAnim.Play("rightDoor"); storeAnimation.Remove(rightAnim); } }
  • 相关阅读:
    随机森林算法
    读论文《BP改进算法在哮喘症状-证型分类预测中的应用》
    Spss22安装与破解步骤
    python安装pip、numpy、scipy、statsmodels、pandas、matplotlib等
    windows下Python三步安装pip
    LNMP环境下配置PHP错误信息提示
    SAE临时文件读写例子 SAE_TMP_PATH
    新浪sae 微信公众平台 输出 返回 打印对象
    PHP 易混 知识
    thinkphp tp5 模板文件 循环输出 bootstrap 模态框 弹窗 获取 微信媒体文件素材 media_id
  • 原文地址:https://www.cnblogs.com/Study088/p/8678265.html
Copyright © 2011-2022 走看看