在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…
首先将PhysicalBody和 categoryBitMask + contactTestBitMask .这两个基本上是在说SCNNode主体是什么类别,以及它可以与哪些类别发生冲突.
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屋!