ARKit Ball Pass through Torus hole collision detection

前提是你 提交于 2020-01-06 06:35:19

问题


I have one ball node and one SCNTorus I am able to pass ball thorough torus node.

I have added collision and

I am able to detect collision when ball pass through the torus using SCNPhysicsContactDelegate But

public func physicsWorld(_ world: SCNPhysicsWorld, didEnd contact: SCNPhysicsContact) called multiple times.

public func physicsWorld(_ world: SCNPhysicsWorld, didEnd contact: SCNPhysicsContact) {
    //        print("Ended collision ")
    print(contact.nodeA.name)
    print(contact.nodeB.name)
    print(world.timeStep)
    print("contact.contactPoint : ",contact.contactPoint)
    print("contact.contactNormal: ",contact.contactNormal)

}

Here is Log

Optional("ball")
Optional("CoreOfTorus")
0.0166666666666667
contact.contactPoint :  SCNVector3(x: -0.46944052, y: 0.732995808, z: -0.102437101)
contact.contactNormal:  SCNVector3(x: 0.599724174, y: -0.597007394, z: -0.532835066)
Optional("ball")
Optional("CoreOfTorus")
0.0166666666666667
contact.contactPoint :  SCNVector3(x: -0.465598524, y: 0.730407655, z: -0.0885346532)
contact.contactNormal:  SCNVector3(x: 0.456919283, y: -0.479364365, z: -0.749289393)
Optional("ball")
Optional("CoreOfTorus")
0.0166666666666667
contact.contactPoint :  SCNVector3(x: -0.450406432, y: 0.740066886, z: -0.112132818)
contact.contactNormal:  SCNVector3(x: 0.20927684, y: -0.901745498, z: -0.378230304)
Optional("ball")
Optional("CoreOfTorus")
0.0166666666666667
contact.contactPoint :  SCNVector3(x: -0.450883865, y: 0.730787694, z: -0.130000055)
contact.contactNormal:  SCNVector3(x: 0.318059504, y: -0.937629461, z: 0.140318558)

See it is called 4 Times how to fix that ?

来源:https://stackoverflow.com/questions/51135793/arkit-ball-pass-through-torus-hole-collision-detection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!