unity现在的标签跟随相机脚本在一些情况下旋转角度不统一怎么破??
3条回答 默认 最新
- 带酒书生 2022-04-13 03:17关注本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报ZYX1061775772 2022-04-13 03:28
using UnityEngine;
public class AlwaysFaceCameraTool : MonoBehaviour
{public bool xAxisOnly = false; public bool yAxisOnly = false; public bool zAxisOnly = false; private Transform myTransform = null; void Awake() { myTransform = transform; } void Update() { if ((myTransform != null) && (UnityEngine.Camera.main != null)) { if (xAxisOnly) { myTransform.LookAt(new Vector3(myTransform.position.x, UnityEngine.Camera.main.transform.position.y, UnityEngine.Camera.main.transform.position.z)); }else if (yAxisOnly) { myTransform.LookAt(new Vector3(UnityEngine.Camera.main.transform.position.x, myTransform.position.y, UnityEngine.Camera.main.transform.position.z)); }else if (zAxisOnly) { myTransform.LookAt(new Vector3(UnityEngine.Camera.main.transform.position.x, UnityEngine.Camera.main.transform.position.z, myTransform.position.z)); } else { myTransform.LookAt(UnityEngine.Camera.main.transform); } } }
}
赞回复展开全部6条评论
悬赏问题
- ¥15 怎么修改鸿蒙app的UI及功能设计
- ¥20 双硬盘安装Ubuntu后windows 无法挂载硬盘
- ¥15 帮我利用jupyter 运行一个正确的代码
- ¥15 如何使用Gephi软件和Python包中的GephiStreamer交互
- ¥15 sqlite加密问题咨询
- ¥15 appdesigner接收不到udp组播的数据
- ¥15 verilog 非阻塞赋值下的移位拼接错误
- ¥100 两个按钮控制一个LED
- ¥15 用C语言写离散数学相关问题
- ¥30 如何用python的GephiStreamer连接到gephi中,把Python和Gephi的具体操作过程都展示,重点回答Gephi软件的调试,以及如果代码的端口在浏览器中无法显示怎么处理