位置: 编程技术 - 正文

unity中被瞄准的对象显示血条或子物体(原理)(unity锚点)

编辑:rootadmin

推荐整理分享unity中被瞄准的对象显示血条或子物体(原理)(unity锚点),希望有所帮助,仅作参考,欢迎阅读内容。

文章相关热门搜索词:unity 准星,unity自瞄,unity准星跟着鼠标,unity调整锚点,unity 准星,unity 准星,unity瞄准镜,unity 准星,内容如对您有帮助,希望把文章链接给更多的朋友!

如图 鼠标放在终点的cube显示出 Sphere;

这个可以用来做瞄准物体显示血条,在端游中经常看见的功能

unity中被瞄准的对象显示血条或子物体(原理)(unity锚点)

代码如下:

using UnityEngine;using System.Collections;public class CubeSph : MonoBehaviour{ public GameObject sph; // Use this for initialization void Start() { sph = transform.Find("Sphere").gameObject; sph.SetActive(false); } // Update is called once per frame void Update() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hit; if (Physics.Raycast(ray, out hit)) { print("hit.name=" &#; hit.transform.tag); if (hit.transform.tag == "enemy") //把cube的tag设置为 enemy { sph = hit.transform.FindChild("Sphere").gameObject; sph.SetActive(true); } } else { print("没有"); sph.SetActive(false); } }}

蛮牛博客:

版权声明:本文为博主原创文章,未经博主允许不得转载。

unity 读取xml 信息 1、首先在unity工程中Resources/XML目录下创建xml文件:xmls.xml;如:?xmlversion=1.0encoding=utf-8?rootparentname=Lilychildname=L/childchildname=Lapple/childchildname=L大/chil

Unity shader 官网文档全方位学习(一) What??Shader,看起来好高级的样子,是的,这是Unity中高级进阶的必备。因此,兄弟我就在此记下我学习官网的一些心得。此为一。主要介绍些SurfaceShaders

Particle system study section 1 Preview:1.Theparticlesystemexistthephenomenonofscalingwithcameraviewpoint.2.Changethelegacyparticlesystemintonewparticlesystem.Details:1.Aftereffectsparticlesystem.Thetextureofparticlesystemisimageseq

本文链接地址:https://www.jiuchutong.com/biancheng/369205.html 转载请保留说明!

上一篇:Unity中的对象池用法(unity对象池优缺点)

下一篇:unity 读取xml 信息(unity 读取xml文件)

免责声明:网站部分图片文字素材来源于网络,如有侵权,请及时告知,我们会第一时间删除,谢谢! 邮箱:opceo@qq.com

鄂ICP备2023003026号

网站地图: 企业信息 工商信息 财税知识 网络常识 编程技术

友情链接: 武汉网站建设 电脑维修 湖南楚通运网络