physics - ARKit 物理对象逐步通过跟踪平面
问题描述
我目前正在尝试修改苹果提供的平面跟踪演示,以使小立方体弹丸从应用程序创建的跟踪平面反弹。
我已将物理实体添加到各自的射弹和墙壁,但由于某种原因,射弹继续忽略碰撞并只是穿过墙壁的阶段。我尝试添加和删除位掩码,但它们似乎没有任何影响。
这是我目前正在为我的履带飞机做的事情:
init (anchor: ARPlaneAnchor, in sceneView: ARSCNView) {
guard let meshGeometry = ARSCNPlaneGeometry(device: sceneView.device!) else {
fatalError("CANNOT CREATE GEOMETRY")
}
meshGeometry.update(from: anchor.geometry)
meshNode = SCNNode(geometry: meshGeometry)
meshNode.name = "ENV."
super.init()
self.setupMeshVisualStyle()
let body = SCNPhysicsBody(type: .static, shape: nil)
meshNode.physicsBody = body
addChildNode(meshNode)
}
这是子弹物理实现
class func spawnBullet() -> SCNNode {
// Omitted code (just setting size and stuff)
let cubeNode = SCNNode(geometry: cubeGeometry)
cubeNode.name = "BULLET"
let physicsBody = SCNPhysicsBody(type: SCNPhysicsBodyType.dynamic, shape: nil)
physicsBody.isAffectedByGravity = false
physicsBody.damping = 0
physicsBody.categoryBitMask = CollisionCategory.bullet.rawValue
physicsBody.collisionBitMask = CollisionCategory.env.rawValue | CollisionCategory.player.rawValue
physicsBody.continuousCollisionDetectionThreshold = 0.01;
cubeNode.physicsBody = physicsBody
return cubeNode
}
我创建了一个单独的 SCNPlane 对象,其物理体设置与跟踪平面设置完全相同。奇怪的是,子弹成功地从 SCNPlane 上相撞,但它们继续以完全相同的设置穿过被跟踪的飞机。
解决方案
推荐阅读
- javascript - 如何使用 jQuery 在 .html() 中不解释“<”?
- java - 未来的日历 DatePicker
- c - 管道如何在c中工作?
- ios - 具有两个表视图和标签的 Stackview 导致重叠
- reactjs - 警告:列表中的每个孩子都应该有一个唯一的“关键”道具,使待办事项列表做出反应
- ansible - 如何设置事实女巫在 Ansible 角色的所有主机上可见
- excel - 提取未关闭的过期项目
- java - 用于在数据库表中搜索子字符串的 MySQL 类似查询
- sql - Oracle 中的多个内联函数
- android - 如何在首先在 Linux 上制作并导入 Windows 的项目上修复“无法进行 Kotlin 项目配置”