当前位置:网站首页>UnityAPI-Ray-Physics
UnityAPI-Ray-Physics
2022-08-02 14:12:00 【莉萝爱萝莉】
1. Ray变量
| 变量 | 描述 |
|---|---|
| origin | 射线起始点 |
| direction | 射线方向(单位距离) |
Camera.main.ScreenPointToRay() 从屏幕上的一个点发出射线,方向为摄像机正交、透视渲染的方向。
2. RaycastHit变量
| 变量 | 描述 |
|---|---|
| collider | 碰撞器 |
| point | 碰撞点 |
| rigidbody | 碰撞刚体 |
| distance | 射线长度 |
| normal | 射线碰撞面的法线 |
collider.gameObject 获得这个对象 |
3. Physics.Raycast
// 射线碰撞一个
bool Raycast(Ray ray, out RaycastHit hitInfo, float maxDistance, int layerMask)
// 射线碰撞所有
RaycastHit[] Physics.RaycastAll(Vector3 origin, Vector3 direction, float maxDistance, int layerMask);
// 自定义检测
Physics.Raycast(transform.position, Vector3.back, 2f, LayerMask.GetMask("Playaer"));
// 例
Ray ray = new Ray(transform.position + transform.forward, transform.forward);
RaycastHit vd;
Physics.Raycast(ray, out vd, Mathf.Infinity, LayerMask.GetMask("UI", "Water"));
print(vd.point);
4. 范围性物理检测
Physics.OverlapSphere(Vector3 position, float radius, int layerMask);
Physics2D.OverlapCircle(Vector2 point, float radius, int layerMask);

边栏推荐
- 总结计算机网络超全面试题
- 5.事务管理
- How to update Win11 sound card driver?Win11 sound card driver update method
- 推开机电的大门《电路》(三):说说不一样的电阻与电导
- Win10 computer can't read U disk?Don't recognize U disk how to solve?
- What should I do if the Win10 system sets the application identity to automatically prompt for access denied?
- Golang 垃圾回收机制详解
- 极简式 Unity 获取 bilibili 直播弹幕、SC、上舰、礼物等 插件
- Problems related to prime numbers - small notes
- Test case exercises
猜你喜欢

Open the door to electricity "Circuit" (3): Talk about different resistance and conductance

二叉树遍历之后序遍历(非递归、递归)入门详解

Spark及相关生态组件安装配置——快速回忆

Based on the least squares linear regression equation coefficient estimation

倍增和稀疏表

Detailed introduction to drawing complex surfaces using the plot_surface command

TCP三次握手、四次挥手

5. Transaction management

Win10 computer can't read U disk?Don't recognize U disk how to solve?

Software Testing Basics (Back)
随机推荐
二叉树创建之层次法入门详解
背包问题-动态规划-理论篇
第二十七章:时间复杂度与优化
IPV4和IPV6是什么?
KiCad Common Shortcuts
Redis common interview questions
couldn't find 'libflutter.so' --flutter
总结计算机网络超全面试题
远程连接Ubuntu中的Mysql
软件测试基础知识(背)
Installation and configuration of Spark and related ecological components - quick recall
pygame draw arc
Spark及相关生态组件安装配置——快速回忆
一篇文章彻底理解Redis的持久化:RDB、AOF
Happy, 9/28 scene collection
7. Redis
剑指offer:合并两个排序的链表
5. Transaction management
Open the door of electricity "Circuit" (1): voltage, current, reference direction
MATLAB绘图函数plot详解