O'Reilly logo

Swift Game Development - Third Edition by Stephen Haney, Siddharth Shekar

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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: ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required