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

前端 未结 4 1425
走了就别回头了
走了就别回头了 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:57

    You need to take Jimi's answer and give the ball a color or texture to see it:

    let ball = SCNSphere(radius: 0.02)
    ball.firstMaterial?.diffuse.contents = UIColor.red
    let ballNode = SCNNode(geometry: ball)
    ballNode.position = SCNVector3Make(0, 0, -0.2)
    self.sceneView.pointOfView?.addChildNode(ballNode)
    

提交回复
热议问题