Adding Game Objects

Create a new setupGame function. We start adding game objects to the scene. To do this, add the following to the setupGame function.

Stop detecting planes

The first thing we do in the setupGame function is disable the checking of planes in the scene. Add the following code to change the configuration and run the new configuration:

configuration.planeDetection = ARWorldTrackingConfiguration.PlaneDetection(rawValue: 0)
sceneView.session.run(configuration)

Adding light source

Then we add a light source to the scene:

 let directionLight = SCNLight() directionLight.type = SCNLight.LightType.directional directionLight.castsShadow = true directionLight.shadowRadius = 200 directionLight.shadowColor = UIColor(red: 0, green: 0, blue: 0, alpha: ...

Get Swift Game Development - Third Edition now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.