title: In SpriteKit, make arrow follow target once it hit it
body: <p>My game has a target which moved from right to left, once an arrow hit it they should move along together from right to left. I was able to make it work but it's not perfect - the arrow is kind of shaking in the target and it sometimes goes off the screen. I believe that its related to the frame rate but I am not sure how to fix it.</p>
  
  <p>This is my code:</p>
  
  <pre><code>func arrowCollideWithTarget() {
      arrows.last!.physicsBody?.velocity = CGVector(dx: 0, dy: 0)
  
      let followAction = SKAction.customAction(withDuration: TimeInterval(Int.max)) {
          node, elapsedTime in
  
          node.position.x += (self.targetLocation?.x)! - (self.latestTargetLocation?.x)!
      }
  
      arrows.last!.run(followAction)
  
  }
  </code></pre>