当前位置:网站首页>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);
边栏推荐
- Masters and Masters
- 倍增和稀疏表
- Introduction to MATLAB drawing functions ezplot explanation
- 软件测试基础知识(背)
- 推开机电的大门《电路》(二):功率计算与判断
- Detailed explanation of MATLAB drawing function fplot
- Open the door of power and electricity "Circuit" (2): Power Calculation and Judgment
- Network Security Packet Capture
- 富文本编辑
- Codeforces Round #605 (Div. 3)
猜你喜欢
[System Design and Implementation] Flink-based distracted driving prediction and data analysis system
Win11 system cannot find dll file how to fix
In-depth understanding of Golang's Map
Redis的线程模型
unity-shader(中级)
STM32LL library - USART interrupt to receive variable length information
Codeforces Round #605 (Div. 3)
【STM32学习1】基础知识与概念明晰
cmake配置libtorch报错Failed to compute shorthash for libnvrtc.so
Introduction to MATLAB drawing functions ezplot explanation
随机推荐
【STM32学习1】基础知识与概念明晰
pygame拖动条的实现方法
Open the door to electricity "Circuit" (3): Talk about different resistance and conductance
动态规划理论篇
快速排序
【离散化+前缀和】Acwing802. 区间和
General code for pytorch model to libtorch and onnx format
unity-shader(中级)
二叉排序树与 set、map
7.Redis
质数相关问题-小记
TCP三次握手、四次挥手
倍增和稀疏表
MATLAB图形加标注的基本方法入门简介
深入理解Mysql索引底层数据结构与算法
Failed to install using npx -p @storybook/cli sb init, build a dedicated storybook by hand
Mysql之MVCC
Use libcurl to upload the image of Opencv Mat to the file server, based on two methods of post request and ftp protocol
KiCad常用快捷键
面试汇总