Unity学习笔记(3):一些常用API和应用场景
2024-08-25 12:40:50
Mathf.Lerp(float a,float b,float t)插值函数,当a < b时往a中插入t,以此来实现颜色,声音等渐变效果。
GameObject.FindWithTag(string tag)通过标签得到实例化的对象,实现跨脚本操作对象
GameObject.GetComponent<>()获得对象的组件
控制物体旋转相关:
Quaternion: 四元数
void Rotating(float h, float v)
{
Vector3 targetDir = new Vector3(h, 0, v);
Quaternion targetRotation = Quaternion.LookRotation(targetDir, Vector3.up);
Rigidbody r = GetComponent<Rigidbody>();
Quaternion newRotation = Quaternion.Lerp(r.rotation, targetRotation, turnSmoothing * Time.deltaTime);
r.MoveRotation(newRotation);
}
h为水平输入,v为垂直输入,该代码实现角色根据水平方向的输入旋转的功能
最新文章
- mysql乱码解决
- Nodejs基础中间件Connect
- JavaScript DOM 编程艺术(第2版)读书笔记 (9)
- HBase Error: connection object not serializable
- QT软键盘
- SQL-Server索引漫谈
- java学习面向对象之this
- 解决android studio 创建新项目后假死
- dropdownlist绑定和选中
- 模拟JQUERY的延迟方法绑定
- android随记
- Windows Azure Virtual Machine (34) 保护Azure虚拟机
- mkdir 命令详解
- PAT1078 Hashing 坑爹
- 支付宝红包口令自动复制到剪贴板脚本js,安卓,IOS通用版
- 第2章 术语 - Identity Server 4 中文文档(v1.0.0)
- 用人类社会工程学对C语言中的一些基本概念的剖析与理解
- 「洛谷1903」「BZOJ2120」「国家集训队」数颜色【带修莫队,树套树】
- 牛客练习赛 26 C题 城市规划【贪心】
- 访问 Google