I have placed 4 images in a circle around my trigger on ARKit, and I'm trying to figure out a way to create a bouncy animation before the images get to their final position as I move and rotate the image reference. Imagine it as a compass with the AR letters (N-S-E-W) and when I rotate it, they'd animate towards its new position, overshoot it by about 5-10% and then animate back towards it.
What I'm doing so far is calculating each change in position on the renderer delegate like so:
func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) {
print("Position: \(node.position)")
animateFaces(in: node)
}
static func animateFaces(in node: SCNNode) {
for i in 0..<node.childNodes.count {
node.childNodes[i].runAction(
SCNAction.sequence([
SCNAction.move(to: calculatePosition(ofIndex: i, around: node, withBounceOf: CGFloat(1.2)), duration: 0.5),
SCNAction.move(to: calculatePosition(ofIndex: i, around: node), duration: 0.5)
])
)
}
}
However, the printed positions are misleading since when adding child nodes on ARKit2 the position of the recognized image is always SCNVector3(0,0,0) (different than the node for some reason).
Any ideas on how I could achieve this?