当前位置:网站首页>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);

边栏推荐
- 二叉树遍历之后序遍历(非递归、递归)入门详解
- 4.发布帖子,评论帖子
- Detailed introduction to drawing complex surfaces using the plot_surface command
- Compilation error D8021: Invalid numeric argument '/Wextra' cl command line error d8021 invalid numeric argument '/Wextra'
- 永久更改pip源
- 剑指offer:在O(1)时间删除链表结点
- yolov5官方代码解读——前向传播
- Win10 computer can't read U disk?Don't recognize U disk how to solve?
- MATLAB绘图函数fplot详解
- Introduction to MATLAB drawing functions ezplot explanation
猜你喜欢
随机推荐
Detailed introduction to drawing complex surfaces using the plot_surface command
Detailed introduction to the hierarchical method of binary tree creation
轻量化AlphaPose
Masters and Masters
MATLAB制作简易小动画入门详解
Problems related to prime numbers - small notes
Network Security Packet Capture
KiCad Common Shortcuts
The SSE instructions into ARM NEON
LeetCode 2354. 优质数对的数目 二进制01表示和集合之间的转换
开心一下,9/28名场面合集
如何用硬币模拟1/3的概率,以及任意概率?
Redis common interview questions
LeetCode 2343. 裁剪数字后查询第 K 小的数字 暴力+语法考察
专硕与学硕
casbin模型
Manifest merger failed : Attribute [email protected] value=
二叉树创建之层次法入门详解
动态规划理论篇
7.Redis









