Tap / Select Node in SceneKit (Swift)

前端 未结 1 1320
无人及你
无人及你 2021-02-06 04:05

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

相关标签:
1条回答
  • 2021-02-06 04:36

    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 ...
    }
    
    0 讨论(0)
提交回复
热议问题