
[Unity][Animator]抽奖卡牌
发布日期:2021-05-09 11:58:29
浏览次数:4
分类:技术文章
本文共 2336 字,大约阅读时间需要 7 分钟。
主摄像机的 Rotation的 X 为90,使其正对着Panel
using UnityEngine;using UnityEngine.AI;public class Test_Card : MonoBehaviour { public Camera cam;//主摄像机 public int hitDistance = 1000; ////// 抽奖卡牌 实体 /// public Transform card1; ////// 抽奖卡牌 实体 /// public Transform card2; ////// 抽奖卡牌 实体 /// public Transform card3; ////// 抽奖卡牌 实体,移动的目的地 /// public Transform trans_Pos1; ////// 抽奖卡牌 实体,移动的目的地 /// public Transform trans_Pos2; ////// 抽奖卡牌 实体,移动的目的地 /// public Transform trans_Pos3; // Use this for initialization 当程序 运行时,一开始运行的代码 void Start () { if (card1 != null && trans_Pos2 != null) { card1.GetComponent().SetDestination(trans_Pos2.position); ;//using UnityEngine.AI; card1.transform.GetComponent ().Play("TestCard_Card", 0);//播放动画 } if (card2 != null && trans_Pos3 != null) { card2.GetComponent ().SetDestination(trans_Pos3.position); ;//using UnityEngine.AI; card2.transform.GetComponent ().Play("TestCard_Card", 0); } if (card3 != null && trans_Pos1 != null) { card3.GetComponent ().SetDestination(trans_Pos1.position); ;//using UnityEngine.AI; card3.transform.GetComponent ().Play("TestCard_Card", 0); } } // Update is called once per frame void Update () { Ray ray = cam.ScreenPointToRay(Input.mousePosition); RaycastHit hit; int layA = LayerMask.NameToLayer("Card"); if ( Physics.Raycast( ray, out hit, 1000, (1 << layA) ) //&& hit.collider.gameObject.layer == LayerMask.NameToLayer("Floor") )//从 主摄像机发出射线 { if (hit.collider.gameObject.layer == layA && Input.GetMouseButton(1))// 判断鼠标点击右键 { Animator animator; //Debug.Log(" hit.point:" + hit.point); animator = hit.transform.GetComponent (); //animator.Play("TestCard_Card",0);//播放卡牌动画 animator.SetBool("isTrans", true); } if (Input.GetMouseButton(0) && hit.collider.gameObject.layer == layA && hit.transform.GetComponent () != null)// 判断鼠标点击左键 { Animator animator; //Debug.Log(" hit.point:" + hit.point); animator = hit.transform.GetComponent (); //animator.Play("showReward", 0);//播放卡牌动画 animator.SetBool("isClick", true); animator.SetBool("isTrans", false); } } }}
参考资料:
1.
2.
3.
转载地址:https://blog.csdn.net/BuladeMian/article/details/88851240 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
留言是一种美德,欢迎回访!
[***.207.175.100]2023年09月15日 20时35分51秒
关于作者

喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
实现嵌入式sql的方法之proc编程
2019-03-08
Mysql中的中文乱码问题
2019-03-08
QT基础知识
2019-03-08
QT基本知识(第二天)
2019-03-08
QT基础知识-画图和文件(第三天)
2019-03-08
Linux——实现简单的交互式shell
2019-03-08
计算机网络——概述
2019-03-08
计算机网络——物理层
2019-03-08
计算机网络——数据链路层
2019-03-08
计算机网络——网络层
2019-03-08
计算机网络——传输层
2019-03-08
计算机网络——应用层
2019-03-08
Linux——网络编程(网络协议基础、TCP、UDP、常用网络术语)
2019-03-08
Linux——网络编程(三次握手、并发、多进程并发服务器的实现)
2019-03-08
Linux——网络编程(TCP状态转换、select、poll)
2019-03-08
Linux——网络编程(epoll、epoll反应堆、心跳、线程池)
2019-03-08
Linux——网络编程(UDP、广播、组播、domain)
2019-03-08
二叉排序树的创建遍历与插入删除操作
2019-03-08
平衡二叉树的建立查考插入删除操作
2019-03-08
序列式容器——deque、stack、queue
2019-03-08