ARKit - Applying Force in User's Phone Direction

前端 未结 1 615
孤独总比滥情好
孤独总比滥情好 2021-01-15 12:58

I have the following code that creates a SCNBox and shoots it on the screen. This works but as soon as I turn the phone in any other direction then the force impulse does no

相关标签:
1条回答
  • 2021-01-15 13:34

    On line 26 you're passing a constant vector to applyForce. That method takes a vector in world space, so passing a constant vector means you're always applying a force in the same direction — if you want a direction that's based on the direction the camera or something else is pointing, you'll need to calculate a vector based on that direction.

    The (new) SCNNode property worldFront might prove helpful here — it gives you the direction a node is pointing, automatically converted to world space, so it's useful with physics methods. (Though you might want to scale it.)

    0 讨论(0)
提交回复
热议问题