人生如白驹过隙,忽然而已|

云鲸啊

园龄:3年5个月粉丝:5关注:4

unity学习笔记(3)-物体检测

1.https://blog.csdn.net/derbi123123/article/details/108417997#:~:text=Unity检测 一定范围内的物品,显示物品图标是游戏的常见功能了,一般有三种 方法 ,第一种是通过触发器去 检测 常见用:Physics.OverlapSphere,(target.position%2C searchRadius%2C 1 << LayerMask.NameToLayer (layMaskName))%3B相交球。 参数1,是相交球的原点位置,第二个是球的半径,第三个参数是可选参数可以是不同层级
2.https://blog.csdn.net/l773575310/article/details/73251093
3.https://blog.csdn.net/qq_42194657/article/details/106075532
4.圆形检测 float tmpDis = Vector3.Distance(hero.position, transform.position);获取位置相减从而获取长度。
5.如果物体速度过快,一帧内穿越该物体,则应该修改其碰撞模式,各个碰撞模式如下:
Discrete(离散型检测模式)就是普通的默认状态;
Continuous(连续检测)则是更加精细的碰撞检测,但是很耗资源;在这种状态下,当这个刚体与其他普通刚体碰撞时,仍将使用Discrete的碰撞检测,但是与没有刚体的Mesh Collider碰撞时就会连续检测了。
Continuous dynamic(动态连续检测)则是对没有刚体的Mesh Collider或是对处在Continuous或是Continuous Dynamic状态下的刚体使用连续碰撞检测,对其他的刚体使用普通的Discrete检测。
但是!!!必须得注意的是:
(1).Continuous/Continuous dynamic(连续检测)–对物理性能有很大的影响,所以如果高速运动的物体的碰撞没有问题,应该设置为默认的 Discrete

(2).Continuous/Continuous dynamic – 只支持使用Box,Sphere和Capusle碰撞器的刚体。(这一点是在以往网上的资料上发现的,查了Unity2017最新版手册,发现确实有说到Continuous支持Box,Sphere和Capusle)

(3).2018之后又出了一个Continuous Speculative 这里官方的API解释是要比Continuous和Dynamic的方式这两种方式更加的节省性能,是扫描方式的进行连续碰撞检测。(猜测:才物体静止的时候不进行检测节省性能。在有位移的时候才进行连续碰撞检测)
总结:
1.Discrete适用于大部分刚体

2.Continuous适用于将有可能会被高速移动物体撞上的物体

3.Continuous Dynamic适用于高速移动的物体

使用连续碰撞检测(Continuous和Continuous Dynamic)前提:
刚体和刚体: 刚体的碰撞器必须是Box,Sphere,Capusle.
刚体和非刚体(静态碰撞器): 刚体物体的碰撞器必须是Box,Sphere,Capusle,非刚体物体的碰撞器必须是Mesh。

本文作者:云鲸啊

本文链接:https://www.cnblogs.com/yunjing/p/15851653.html

版权声明:本作品采用知识共享署名-非商业性使用-禁止演绎 2.5 中国大陆许可协议进行许可。

posted @   云鲸啊  阅读(247)  评论(0编辑  收藏  举报
点击右上角即可分享
微信分享提示
评论
收藏
关注
推荐
深色
回顶
收起
  1. 1 ocean eyes bili
ocean eyes - bili
00:00 / 00:00
An audio error has occurred.

作词 : Finneas O'Connell

作曲 : Finneas O'Connell

I've been watching you

For some time

Can't stop staring

At those ocean eye

Burning cities

And napalm skies

Fifteen flares inside those ocean eyes

Your ocean eyes

No fair

You really know how to make me cry

When you give me those ocean eyes

I'm scared

I've never fallen from quite this high

Falling into your ocean eyes

Those ocean eyes

I've been walking through

A world gone blind

Can't stop thinking of your diamond mind

Can't stop thinking of your diamond mind

Careful creature

Careful creature

Made friends with time

He left her lonely with a diamond mind

He left her lonely with a diamond mind

And those ocean eyes

And those ocean eyes

No fair

You really know how to make me cry

You really know how to make me cry

When you give me those ocean eyes

I'm scared

I've never fallen from quite this high

I've never fallen from quite this high

Falling into your ocean eyes

Those ocean eyes

Those ocean eyes

No fair

No fair

You really know how to make me cry

You really know how to make me cry

When you give me those ocean eyes

I'm scared

I'm scared

I've never fallen from quite this high

I've never fallen from quite this high

Falling into your ocean eyes

Those ocean eyes

Those ocean eyes