3

In my ARKit app I have an animated character (stored as T-Bone Model in a SCN file). The Animations are taken from several DAE files and applied to the model using SCNAnimationPlayer like so:

let myAnimation = Animations.configMyAnimationFunction()
myAnimation.stop()
enemyNode.childNodes[2].addAnimationPlayer(myAnimation, forKey: "myKey")
enemyNode.childNodes[2].animationPlayer(forKey: "myKey")?.play()

the Animation plays perfectly.

Now I do "hit-test" against the animated geometry, like this:

let currentTouchPoint = touches.first?.location(in: self.sceneView)
let hitTest = sceneView.hitTest(currentTouchPoint!, options: [SCNHitTestOption.categoryBitMask: NodeCategory.catEnemy.rawValue, SCNHitTestOption.searchMode: SCNHitTestSearchMode.any.rawValue as NSNumber])
let hitObject = hitTest.first?.node // let that stores the hitTest

if hitObject != nil {

      // code...

      let hitLocation = hitTest.first?.worldCoordinates

      // code...
}

I want to use the result from "worldCoordinates". But it seems, that the result always contains the coordinates from the static T-Bone Model, instead of the location on which it is during the animated runtime.

Imagine the animated model is clapping its hands (as a humanoid character) or touching the ground. When I touch the Models hands the hittest works and returns the result, but finally at the wrong coordinates.

Apple Docs on worldCoordinates is like this: "The point of intersection between the geometry and the search ray, in the scene’s world coordinate system." I also tried localCoordinates, but with even less success.

How can I determine the real coordinates at the current touch location on the geometry during the model is animated?

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
ZAY
  • 3,882
  • 2
  • 13
  • 21
  • Possible duplicate of [Xcode 7 SceneKit object's position property does not update when moved?](https://stackoverflow.com/questions/31927113/xcode-7-scenekit-objects-position-property-does-not-update-when-moved) – mnuages Feb 25 '19 at 13:28
  • 1
    It's not the same. I am not looking for the Node's position by its presentation - I am looking for the exact Intersection Point on the ISO-Surface of the animated geometry found by a hittest. The Geometry is a human like character. – ZAY Feb 25 '19 at 17:29

0 Answers0