How do you attach an object to your camera position with ARKit Swift?

前端 未结 4 1426
走了就别回头了
走了就别回头了 2021-02-02 03:08

I have moving objects which I want to have be able to collide with me the player. I have the ability to launch objects from me by getting my current position/direction at that t

4条回答
  •  粉色の甜心
    2021-02-02 03:39

    ARSCNView has a property 'pointOfView'. You can attach a child node to it.

    let ball = SCNSphere(radius: 0.02)
    ballNode = SCNNode(geometry: ball)
    ballNode?.position = SCNVector3Make(0, 0, -0.2)
    sceneView.pointOfView?.addChildNode(ballNode!)
    

    The node will follow your camera anywhere you go.

提交回复
热议问题