0

So i am starting to learn scenekit and i have some models i want to try on the iphone simulator so i just changed

let scene = SCNScene(named: "art.scassets/ship.scn")!

which works fine in the scenekit default file to

let scene = SCNScene(named: "art.scassets/battleship.scn")!

which is a 3d model of a battleship but when i run it it gives me an error near a line of code:

let ship = scene.rootNode.childNodeWithName("ship", recursively: true)!

The error says: Thread 1: EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP,subcode=0x0) And: fatal error: unexpectedly found nil while unwrapping an Optional value (lldb)

I'm sorry but it is very hard to explain, but if anyone understood what i said please tell me how to import 3d models to scenekit, i haven't found any tutorial that shows how to do that custom 3d models to scenekit

Asphys
  • 175
  • 3
  • 15

1 Answers1

1

If your last line of code above is generating the error it means your scn file doesn't contain a node with the name "ship". If you need to find the names of nodes in a DAE file, open the .dae file in the editor window and click on the little sidebar icon lower left. You can get names, rename and rearrange the hierarchy in this window.

There is an image and a bit more explaination here: Transform and Rotate in Scenekit

Community
  • 1
  • 1
bpedit
  • 1,176
  • 8
  • 22