how to track the position of a node after applying force in Arkit 1.5
我有一个节点(SCNSphere),我在其中应用了force。节点具有
dynamic
SCNNode
使用
physicsBody?.applyForce
一切都很好
问题是在使用武力之后
动态
身体在不断下降
我要追踪那个位置
renderer(_ renderer: SCNSceneRenderer, updateAtTime time: TimeInterval)
我打印
position
属于
SCN节点
但它每次都显示相同的位置,为什么Y位置不减少,因为它是向下的?
就像
<SCNNode: 0x280f29500 'ball' pos(-0.165368 0.3 -0.809096) | geometry=<SCNSphere: 0x280619380 | radius=0.150> | no child>
<SCNNode: 0x280f29500 'ball' pos(-0.165368 0.2 -0.809096) | geometry=<SCNSphere: 0x280619380 | radius=0.150> | no child>
<SCNNode: 0x280f29500 'ball' pos(-0.165368 0.1 -0.809096) | geometry=<SCNSphere: 0x280619380 | radius=0.150> | no child>
如何添加节点
let ballWithOrientation = getNewBallNode() // return ball node + position
let ballNode = ballWithOrientation.ball // it is the SCNNode
self.sceneView.scene.rootNode.addChildNode(ballNode ?? SCNNode()) // Added to the scene
let cameraPosition = self.sceneView.pointOfView?.worldFront
let target = SCNVector3(Double(cameraPosition?.x ?? 1) * forceVector,Double (cameraPosition?.y ?? 1) * forceVector,Double(cameraPosition?.z ?? 1) * forceVector) // Vector of direction
let throwSpeed = self.calculateBestThrowSpeed(origin: ballNode!.position, target:target , timeToTarget: 0.66) Calculated vector with velocity
ballNode?.physicsBody?.applyForce(throwSpeed, asImpulse: true) // apply force
问题
施力后如何跟踪SCNNode的世界位置?