I am working on a game that involves objects(fish) that move across the screen that you need to catch with another object(hook) that you can move up and down. Once the objects make contact the fish's position is supposed to become the same as the hook's. So in did begin contact (which does work, Im sure) I said, when the hook and fish touch make the fishes position become the same as the hooks.
func didBeginContact(contact: SKPhysicsContact) {
let firstBody = contact.bodyA
let secondBody = contact.bodyB
if firstBody.categoryBitMask == physicsCategory.fishHook && secondBody.categoryBitMask == physicsCategory.greenFish || firstBody.categoryBitMask == physicsCategory.greenFish && secondBody.categoryBitMask == physicsCategory.fishHook{
CollisionWithfishHook(firstBody.node as! SKSprit
eNode, greenFish: secondBody.node as! SKSpriteNode)
}
}
func CollisionWithfishHook (fishHook: SKSpriteNode, greenFish: SKSpriteNode){
greenFish.position = CGPointMake(fishHook.position.x, fishHook.position.y)
}
For some reason when I run it and they make contact nothing happens. I know that did begin contact is working correctly because when I told it to remove the fish when it touches the hook it works. The problem is I am unable to change the location of the green fish. Why is this and what can I do to fix it?