Project setup and detecting a plane
The first thing that we have to do, before we even set up the project, is change some settings and detect a plane so that our game object will have a plane to start on. In the 3D game in Chapter 11, Introduction to SceneKit, we created the ground on which the player character was placed and can jump from. When we make an AR game, we first need to detect a physical real-world plane on which we want our game objects to be placed.
ARKit for SceneKit provides a specific function that does just that. In fact, there are three functions. The first one is didAddAnchor
, then we have didUpdateAnchor
, and finally we have didDeletAnchor
:
func renderer(_ renderer: SCNSceneRenderer, didAdd node: SCNNode, for anchor: ARAnchor) { } func renderer(_ renderer: SCNSceneRenderer, didUpdate node: SCNNode, for anchor: ARAnchor) { } func renderer(_ renderer: SCNSceneRenderer, didDelete node: SCNNode, for anchor: ARAnchor) { }
DidAddAnchor
checks whether a new anchor...