I would not put this in the update code, try to keep the clutter in the update section, remember that you only have 16 ms to work.
Instead, subclass your node symbol and override the position property. Basically, we say that if your camera is 10 pixels away from your character, move towards your character. We use the key in our action, so that we do not perform multiple actions and synchronization mode, so that the camera moves smoothly to your point, and not instantly.
class MyCharacter : SKSpriteNode
{
override var position : CGPoint
{
didSet
{
if let scene = self.scene, let camera = scene.camera,(abs(position.y - camera.position.y) > 10)
{
let move = SKAction.move(to: position, duration:0.1)
move.timingMode = .easeInEaseOut
camera.run(move,withKey:"moving")
}
}
}
}
Edit: @Epsilon , SKActions SKPhysics , , . didFinishUpdate:
override func didFinishUpdate()
{
if let character = self.character, let camera = self.camera,(abs(character.position.y - camera.position.y) > 10)
{
let move = SKAction.move(to: character.position, duration:0.1)
move.timingMode = .easeInEaseOut
camera.run(move,withKey:"moving")
}
}