PestControl: Player doesn't move

I’m at the beginning of the PestControl section and for the life of me I can’t get the Player to move when I click. A breakpoint inside the “move” function shows that I’m getting to that function and setting the physics body velocity, but no movement results when I continue the program.

I’ve compared my code in all source file line by line to the “Final” code and I can’t see what’s causing the player’s velocity not to cause the player to move. I’ve also compared the GameScene.sks file.

Is there some global physics setting that I’ve missed? Any other thoughts?

Here’s my Player class:

// Player.swift
// PestControl
// Created by Mathew Hartfield on 1/11/17.

import SpriteKit

enum PlayerSettings {
static let playerSpeed: CGFloat = 280.0

class Player: SKSpriteNode {

required init(coder aDecoder: NSCoder) {
fatalError(“Use init()”)

init() {
let texture = SKTexture(imageNamed: “player_ft1”)
super.init(texture: texture, color: .white,
size: texture.size())
name = “Player”
zPosition = 50

physicsBody = SKPhysicsBody(circleOfRadius: size.width/2)
physicsBody?.restitution = 1.0
physicsBody?.linearDamping = 0.5
physicsBody?.friction = 0
physicsBody?.allowsRotation = false
physicsBody?.isDynamic = true


func move(target: CGPoint) {
guard let physicsBody = physicsBody else { return }

let newVelocity = (target - position).normalized()
  * PlayerSettings.playerSpeed
physicsBody.velocity = CGVector(point: newVelocity)


Hmm… I started from scratch and followed the book again and it worked. Clearly I missed something along the way, no idea what.

Thanks for letting me know :slightly_smiling_face: