10

I'm new to SceneKit and 3D spaces in iOS. I'm currently working on a simple game that shows a cube of 28 segments ("mini cubes" if you want).

I want to move the mini cubes by tapping them, but I can't get my head around how to select specific nodes (childnodes of the big cube).

Can anybody help me or post a link to SceneKit tutorials for dummies? I've been looking for days now, and haven't found what I'm looking for.

Cheers

Paulw11
  • 108,386
  • 14
  • 159
  • 186
Sebastian
  • 417
  • 7
  • 8
  • wer you able to move the mini cubes. I am also trying to move a piece of furniture in a 3d scene using my finger. How would I achieve this. The piece of furniture is a node in a living room 3d model. – madLokesh Jul 19 '16 at 06:32

1 Answers1

19

You can hit test the scene view (for example from the location of a tap gesture recognizer), which will give you a list of hit test results. From each result you can get the node (and other information):

let location: CGPoint = // for example from a tap gesture recognizer
let hits = self.sceneView.hitTest(location, options: nil)
if let tappedNode = hits?.first?.node {
    // do something with the tapped node ...
}
David Rönnqvist
  • 56,267
  • 18
  • 167
  • 205