Q:

How to convert a value to CGPoint?

I have the problem that I want to use a variable in an action, which has not the matching type. I therefore get the following error: Cannot convert value of type 'SKSpriteNode' to expected argument type 'CGPoint'.
func enemyProofNextFields() {

    for i in 0...41 {

        if getDistance(knightRed.position, grassTileArray[i].position) > 120 && getDistance(knightRed.position, grassTileArray[i].position) < 121 {

            possibleEnemeyFields.append(grassTileArray[i])
        }
    }

    var lenght = possibleEnemeyFields.count
    let randomNumber = Int.random(in: 0 ... lenght)
    print("Random Enemy Number: \(randomNumber)")
    var position = possibleEnemeyFields[randomNumber]

    let move = SKAction.move(to: position, duration: 0.3) //here is the error
    knightRed.run(SKAction.sequence([move]))

}

For any answer I would be very grateful.

A:

The error is pretty clear: possibleEnemeyFields contains obviously SKSpriteNode instances, but the first parameter of move expects a CGPoint, assumedly the position
You probably mean
let field = possibleEnemeyFields[randomNumber]
let move = SKAction.move(to: field.position, duration: 0.3) 

