Errata for 3D iOS Games by Tutorials v1.1

Page 203, 1st Note box, line 3
Chapter 12: Reference Nodes

Current text:
there’s need to scream and pull your hair out just yet …
…^

Suggested text:
there’s no need to scream and pull your hair out just yet …

Hey Chris, just wanted to note a few code recommendations for Chapter 2:

On page 46, when setting up the spawnShape() method, there’s a var geometry: SCNGeometry. If the default clause in the switch statement always allocates this object, shouldn’t this be a let rather var? As such:

   func spawnShape() {
        let geometry: SCNGeometry
        
        switch ShapeType.random() {

        default:
            geometry = SCNBox(width: 1.0, height: 1.0, length: 1.0, chamferRadius: 0.0)
        }
        
        let geometryNode = SCNNode(geometry: geometry)
        scnScene.rootNode.addChildNode(geometryNode)
    }

Also, I recommend instead of having a setupCamera() method, that most likely makes more sense as a lazy var. Any further configurations to camera positioning, or whatnot, would make more sense for a dedicated setup method rather basic initialization. Following off of this, the scnScene could also be type casted via a calculated variable to prevent having it’s own dedicated method as well:

var scnView: SCNView! {
    return view as! SCNView
}
var scnScene: SCNScene!
lazy var cameraNode: SCNNode! = {
    let cameraNode = SCNNode()
    cameraNode.camera = SCNCamera()
    cameraNode.position = SCNVector3(x: 0, y: 0, z: 10)
    return cameraNode
}()

This way, the proper things are asserted when expected and are a bit more organized and simplified.

In Chapter 3: Physics, page 53, when walking through the project and adding the GameUtils folder, there seems to be no reference where this folder should be located within the project files. When navigating the current project version (v1.1) within the zip files, there seems to be no reference to this folder:

You can extract the files from the Final project, or another project later, but this is probably something that should be added.

PDF Top of Page 169: “Settings: Once again, zero out all the settings, but this time also set
Restitution to 1.”

This makes it seem like Restitution is being set differently for the paddle. However, all of the other objects with physics also have Restitution set to 1.

Did you solve the problem of the paddle disappearing?

Cheers

is there a way to download an iBooks version of the book that automatically updates?

PDF Top of Page 230: “Make sure to position it at (x: 0, y: 2, z: 0)”

For the position of set_restpoint reference, y should be -2, not 2. The diagram correctly shows -2, which puts the pillar directly beneath the ball.

Chapter 5 - page 84 refers to Chapter 21, “Sprite Kit Integration” - which isn’t in v1.1 of the PDF. Is this chapter coming soon?

PDF Page 278/279: The text on page 279 says to pin the Mr Pig View horizontally and vertically in the container and has a diagram which shows it centered horizontally and vertically. The diagram on page 278 shows different constraints, spacing it 24 from top, 24 from left, 24 from right, 44 from bottom. The included project contains still different constraints, spacing it 24 from top, 44 from left, 44 from right, 44 from bottom. Also, the included project has “Clips Subviews” unchecked, which is checked by default (for the image view).

I ran into the same problem. One of the top rails in the Breaker game kept disappearing - very strange.

I seem to have sorted it out here, as follows: select the rail in the scene editor, and go to the attributes inspector. Then hit ‘Unshare’ under ‘Geometry Sharing’.

I did this for each of the rails, and they all seem to be working properly now. I suspect it’s some sort of bug in the scene editor; the ‘original’ version of a copied node gets rendered properly, but the copy is somehow left out. Unsharing the geometry breaks the link to the original node, and makes the ‘copy’ an independent object with its own position in the render queue.

Whether that explanation’s right or wrong, it seems to work…

2 Likes

Thanks for your help.

Page 43:

Working with geometry
In order to create visible content, you need to add a geometry object to a node. A geometry object represents a three-dimensional shape and is created of many points known as vertices.

This implies that objects are made of points, which is only partly true. Perhaps it would be better to say something such as:

'A geometric object represents a three dimensional shape made up of polygons, multi sided shapes. Polygons are often triangles. An object can have many polygons, such as a sphere, or very few, such as a simple cube, which has 6, one for each side. Polygons themselves are made up of vertex points called vertices, and edges, that connect the vertices.

Aside from this very minor matter, I’m off to a good start and enjoying the book. Thanks!

This fix worked for me as well! Thanks.

I had this problem before where the code doesn’t recognized the functions in a Utilities folder. Not sure what causes this. I’ve tried rebuilding and closing the project and re-opening.


I noticed that when I copied the complete folder from the Resources folder it was blue. Instead I created a new Group, orange folder, and copied the individual .swift files in to this folder. This works.

OK, I noticed in the Figure on Page 59 that Create Groups is checked. That fixed the problem.