【发布时间】:2017-12-12 21:50:12
【问题描述】:
我正在尝试确定如何在不为我的 SCNNode 实际创建physicsBody 的情况下进行“hitTest”。
我可以为命中测试方法使用什么替代方法? (包括没有物理实体的节点)。我正在尝试选择屏幕触摸打开的第一个节点
问题,'命中测试'要求节点有一个physicsBody 如果我有一个physicsBody,这会起作用,但是在我添加physicsBody 之前,我需要对我的SCNNode 做一些事情。
我的“environmentContainer”确实有第一个 SCNNode;但是,“results.first”返回了第一个带有物理体的节点,我需要第一个节点(不管它是否有物理体)
case .began:
let results = sceneView.hitTest(firstTouch!, options: [SCNHitTestOption.firstFoundOnly: true])
if results.first != nil {
if environmentContainer.childNodes.contains((results.first?.node)!)
{
firstDragTapOnSelectedNode = true
print("firstDragTapOnSelectedNode = true")
}
else {
// always returns false because 'results.first' is picking up the wrong node which is in a different SCNNode container
print("firstDragTapOnSelectedNode = false")
}
}
case .ended:
firstDragTapOnSelectedNode = false
default: break
}
注意:firstDragTapOnSelectedNode 初始化为 false
【问题讨论】:
标签: ios swift collision-detection scenekit hittest