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 the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.