如何在 ARKit 中没有物理交互的情况下检测渗透? [英] How to detect penetration without physical interaction in ARKit?
问题描述
我有一个固定的激光束 SCNNode 和一个连接在相机前面的检测球 SCNNode.
I have a fixed laser beam SCNNode and a detecting sphere SCNNode attached in front of a camera.
如何在没有物理交互的情况下检测渗透?我没有找到任何线索..
How to detect penetration without physical interaction? I have not found any clue..
-如下面 maxxFrazer 所建议的,我实现了物理交互,如果我的激光束是 .static 并且检测器由相机设置 .kinematic 移动,我就可以注册碰撞.
- as suggested below by maxxFrazer I implemented physical interaction and I'm able to register collision IF my laser beam is .static and detector moved by camera set .kinematic.
推荐答案
您似乎想要使用 SceneKit 解决方案,而不是 RealityKit.并且还想找到两个实际节点何时相交而不是 hitTest 或 raycast 相交?如果是这样,我已经尝试在下面解释如何设置...
It looks like you want to use a SceneKit solution, not RealityKit. And also want to find when two actual nodes intersect rather than a hitTest or raycast? If so, I've attempted to explain how to set that up below…
首先向 SCNNode 添加一个 PhysicsBody,以及一个 categoryBitMask + contactTestBitMask.这两个基本上是在说你的SCNNode body是什么类别,它可以碰撞到什么类别.
First add a physicsBody to the SCNNode, along with a categoryBitMask + contactTestBitMask. These two are basically saying what category your SCNNode body is, and what categories it can collide with.
然后,您还需要将 SCNScene.physicsWorld.contactDelegate 设置为符合 的对象SCNPhysicsContactDelegate,这样你就可以使用在这里找到的physicsWorld回调.
You then also need to set up your SCNScene.physicsWorld.contactDelegate to an object which conforms to SCNPhysicsContactDelegate, this is so you can use the physicsWorld callbacks found here.
关于堆栈溢出的另一个问题可能有助于您完成这项工作:
There's another question on stack overflow which may help in making this work for you:
这篇关于如何在 ARKit 中没有物理交互的情况下检测渗透?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!