3D 对象的交互问题。我发现了 RealityKit 的一些 beta 功能,例如 PhysicsBodyComponent、applyImpulse、addForce、applyAngularImpulse 等。
我试图为对象“花瓶”添加物理特性,并在点击或类似事件时产生对对象的冲动。
真的很奇怪,执行命令后,物理特性正常添加,同时脉冲和力没有添加到对象中(见下文调试输出)。
调试打印输出:
东西1可选(RealityKit.PhysicsBodyComponent(模式:RealityKit.PhysicsBodyMode.dynamic,massProperties:RealityKit.PhysicsMassProperties(质量:0.2,惯性:SIMD3(0.1,0.1,0.1),centerOfMass:(位置:SIMD3(0.0,0.0,0.0) , 方向: simd_quatf(real: 1.0, imag: SIMD3(0.0, 0.0, 0.0)))), 材质: RealityKit.PhysicsMaterialResource, isTranslationLocked: (x: false, y: false, z: false), isRotationLocked: (x:假,y:假,z:假),isContinuousCollisionDetectionEnabled:假,传送:假,userForce:SIMD3(0.0,0.0,0.0),userTorque:SIMD3(0.0,0.0,0.0),userLinearImpulse:SIMD3(0.0,0.0,0.0) ), userAngularImpulse: SIMD3(0.0, 0.0, 0.0)))
东西5可选(RealityKit.PhysicsBodyComponent(模式:RealityKit.PhysicsBodyMode.dynamic,massProperties:RealityKit.PhysicsMassProperties(质量:0.2,惯性:SIMD3(0.1,0.1,0.1),centerOfMass:(位置:SIMD3(0.0,0.0,0.0) , 方向: simd_quatf(real: 1.0, imag: SIMD3(0.0, 0.0, >0.0)))), material: RealityKit.PhysicsMaterialResource, isTranslationLocked: (x: false, y: false, z: false), isRotationLocked: (x :假,y:假,z:假),isContinuousCollisionDetectionEnabled:假,传送:假,userForce:SIMD3(0.0,0.0,0.0),userTorque:SIMD3(0.0,0.0,0.0),userLinearImpulse:SIMD3(0.0,0.0, 0.0), userAngularImpulse: SIMD3(0.0, 0.0, 0.0)))
正如我们所见,函数不会向对象“花瓶”添加冲动和力量。也许我做错了什么。