3D iOS Games by Tutorials Discussion

A place to further our knowledge of 3D game development on iOS.

Does anyone know how to add custom geometry to a scene kit scene editor file? I can add the basics discussed in the book such as a box of sphere. I create my own voxel model using MagicaVoxel and I cannot figure out how to add that to a scene file to use as a reference node. The book provides assets to use but doesn’t explain how the scene files were set up. Any help is much appreciated!

Excellent book, loving it so far!( I’m on page 182).

Observation: It seems that paddle’s sides or the barriers can disappear in the Breaker app. I have an iPhone 5s running iOS 9.3. Xcode doesn’t give any memory warnings either when this happens. This also happens with the example project.

1 Like

I would love to figure this out as well. I’m currently on the second project, but I love using Voxels so I’ll probably need this as well. If you don’t get an answer soon, when I get to the chapter and if I figure it out I’ll post on here. Let me know if you figure it out as well!

I talked to the author of the book on Twitter about this. Export from Magicavoxel to .OBJ, then import into Blender and export as .DEA and when you import that into Xcode it will ask you if you want it as a scene kit object. The author also says “I also do a basic rotation and scaling in Blender before exporting as .DAE”.


Awesome thanks max, this is exactly what I needed. I appreciate this!

I am skipping around various parts of this excellent resource to focus on question most relevant to my project. I have spent some time looking at Chris’ various Gamehelper.swift files for GeometryFighter (3-5), Breaker (6-10), MarbleMaze (14 & 15) & MrPig (16-20). Not surprisingly, each one varies and become a little more complex with each game. One very specific question I have is in all Gamehelper.swift files he has:

      = String(format: "%0\(4)d"

What does %0 \ (4)d mean ?!

I noticed something that confused me. In Chapters 14 & 15 Chris has a Gamehelper.swift file with TWO functions named updateHUD

func updateHUD() {
let scoreFormatted = String(format: "%0\(4)d", score)
labelNode.text = "\(scoreFormatted)"}

func updateHUD(s:String) {
    labelNode.text = s

One passes a string, the other does not. What is relationship between these two? Are they the same? If so, why not combine the two by adding (s:String) and labelNode.text = s so there is only one function named “updateHUD(s:String)”

When he has us call the function (pg 266) in GameViewController.swift:

  func updateHUD() {
    switch game.state {
    case .Playing:
    case .GameOver:
      game.updateHUD("-GAME OVER-")
    case .TapToPlay:
      game.updateHUD("-TAP TO PLAY-")

How do you know which function (both with the same name) it is calling? I assume it is the one that returns a string because he includes a string in the switch statements. But it is a little confusing to me.

Hi there, updateHUD() and updateHUD(s:String) are seen as different methods based on the parameters being passed in. This is commonly known as method overloading. The version that takes a String as input parameter allows you to update the HUD with a custom message. The other one defaults the HUD content with the score details.

String(format: “%0(4)d”, score) - This creates a String representation of the score value, which is a Int type. Not only that, the format: “%0(4)d” part zero fills the string making it 4 characters long. So 0 score value would display as 0000, and 123 as 0123.

Hopefully that all made sense! Thanks for the support!


@chrislanguage Thanks Chris, both explanations make a lot of sense and clear things up! Just learned two new things.


Can anyone point me to where the resources and projects folders are? I am only finding the projects for each chapter in the downloaded folder.

Hi there,

You’ll find the resource folders typically under one of three folders - “starter”, “final” or “challenge”. For chapter 1, you’ll find a resource folder under “01-scenes/projects/starter/resources/”.

Hope that helps. Thanks for your support!

i love this book
im on the end of project 3 now (i went trough the other 2 quickly since i knew this stuff already, yet reading it to see if there might be some better way to do stuff)
it has great stuff explained really good (like using normal maps and stuff)
but for my own game im looking to use a different type of game, not really a maze and not with pearls of life, more with collectables that they need to collect and with enemies
now it comes… lol
i have a question on using normal/light maps
does it use a lot of memory to use them on a player object together with many other objects that are illuminated good ?
i would like to use them on objects in my game that need details, but im afraid ill suck up a lot of the memory, specially on older devices

At the end of Chapter 10, is it expected behavior for the ball to bounce at an irregular angle when hitting the area between bricks and segments of the paddle?

I also have this problem on an iPhone 6S+. The barriers and paddle sides randomly disappear when the ball collides with the bricks, and then re-appear after a few seconds. It doesn’t happen on an iPad 3, though. Both devices running iOS 9.3

Hi @orle, I had a similar problem and was able to resolve by clicking: Geometry Sharing -> “Unshare” (under the Attributes Inspector of Scene Editor) for each of the nodes that were displaying the weird behavior (disappearing / appearing).

For me, the random disappearance happened for both iPhone and iPad (physical devices). The left barrier, and the right node of the paddle kept disappearing and appearing. After clicking Geometry Sharing -> “Unshare” for those nodes, I was able to fix the problem. Hope this helps.


@sanjib , great! it fixed the problem, thanks a lot for your advice!

Hi there,

Glad to hear that you’re enjoying the book! :]

Scene Kit can handle massive textures - 4096x4096 pixels (this is device dependant, I do not know the exact details). Most of the time, you typically won’t use a texture of that magnitude on any character. My suggestion is to try out the same texture for the material at various smaller sizes, until you reach the smallest size that’s still acceptable to the eye. This approach will make sure that you’re not “abusing” the memory.

Another thing to point out is that Scene Kit can “Share” materials - this a great memory saving feature you should definitely make use of. When you “Unshare” the material, an new instance is created.

Coming back to your question - Material textures are definitely memory hogs, try and use/share the same material more than once on multiple objects. This won’t push up the memory usage, regardless of the amount of objects that shares the same material. Try to keep your textures as small as possible - chances are, you’re probably using a too detailed texture map anyways.

Your main concern with older devices should rather be performance. Special material features like normal mapping for example can be very expensive. Keep an eye out not to over-use these special features. If you keep the performance above 60fps, then all should be good from a memory perspective too.

Hope that helps. Thanks for your support!

PS. Good luck with your game! :]

Happens on my iPhone 6 plus also running 9.3

With Mr. Pig, if you close the game (but keep it in multitasking), and come back to it later, the frame rate drops to ~35 fps and all the cars assume the same position. Does this happen to anyone else? I guess this has something to do with actions’ progress not being saved when closing?

Hi @scowart , I followed @sanjib advice a couple of posts above, and it fixed the problem. You should give it a try.