Creating an AR Spritekit project
Open Xcode and create a new project. In the Application tab, select Augmented Reality App:
Next, set the name of the project, the development team, the language, and the content technology:
Once the project is created, sign in with your developer account to run it on the device:
When you run the application, it will need permission to access the camera. Click OK:
Now, move around in the room with the camera and touch the screen. You will see objects created on the screen, and they will scale depending upon how close you are to the object:
The objects in SpriteKit ARKit
are all 2D objects, so they do not have perspective or depth. The object is made to face the camera irrespective of the user's location and orientation. This is called bill boarding.
Let's see how all of this is set in code to make it work. In terms of class structure, you will see that it remains the same. We still have the same Main.Storyboard
, ViewController.swift
, Scene.swift
, and Scene.sks
files...