Run a SKSpriteNode object along a line with drawn with the mouse IN SWIFT

If you let go of the left mouse button, my SKSpriteNode object should move along the line previously "drawn" with the mouse.

My problem is that my sprite node is moving down when I release the left mouse button.

import SpriteKit

class GameScene: SKScene, SKPhysicsContactDelegate {

    let object: SKSpriteNode = SKSpriteNode(imageNamed: "rabbit")

    var actionArray = [SKAction()]

    override func didMove(to view: SKView) {

        physicsWorld.gravity = CGVector(dx: 0, dy: 0)
        physicsWorld.contactDelegate = self

        object.setScale(0.2)
        object.position = CGPoint(x: size.width / 2, y: size.height / 2)
        object.zPosition = 0
        object.physicsBody = SKPhysicsBody(texture: SKTexture(imageNamed: "rabbit"), size: object.size)

        object.physicsBody?.mass = 0
        object.physicsBody?.categoryBitMask = 0
        object.physicsBody?.contactTestBitMask = 1
        object.physicsBody?.collisionBitMask = 0

        addChild(object)

    }

    override func mouseDragged(with event: NSEvent) {

        actionArray.append(SKAction.move(to: event.location(in: self), duration: 1))

    }

    override func mouseUp(with event: NSEvent) {

        object.run(SKAction.sequence(actionArray))

        // Remove all actions from 'actionArray'.
        actionArray.removeAll()

    }

}

I have already tried it as shown below. Now my sprite node moves to the first point, where I pressed down the left mouse button.

override func mouseUp(with event: NSEvent) {

    let removeAllFromActionArray = SKAction.run {

        self.actionArray.removeAll()

    }

    actionArray.append(removeAllFromActionArray)
    object.run(SKAction.sequence(actionArray))

}

I suspect that the bug lies in override func mouseDragged(with event: event). Does anyone know where the error lies or does anyone know another solution?