How to place an SCNNode directly in top of another SCNNode?

Hey!


I am trying to make an app which just places an SCNNode directly in top of another SCNNode. The issue is that the position of the initial SCNNode is not fixed. I tried doing this:


SCNVector3(node.position.x, node.position.y + 2, node.position.z)


But, it does not work.. How do I do it? Please help...

Replies

You need to add your new node as a child of the original node, using addChildNode(_:)


Once added as a child, your new node's position is now relative to its parent's position, so if you want the new node to be directly on top of it's parent (i.e. have the exact same position), then you would simply set the new node's position to SCNVector3(0,0,0), which also happens to be the default position 🙂