This is the code I have for the two nodes. Declarations not included.
//paddle node and its physicsbody
paddle = childNode(withName: "paddle") as! SKSpriteNode
paddle.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: paddle.size.width,
height: paddle.size.height))
paddle.physicsBody?.isDynamic = false
paddle.physicsBody?.affectedByGravity = false;
paddle.physicsBody?.friction = 100
paddle.physicsBody?.restitution = 0
//paddle.physicsBody?.linearDamping = 1
//paddle.physicsBody?.angularDamping = 1
//Second node
rect.position = CGPoint(x: 100, y:500)
rect.fillColor = UIColor(hue: 215/360, saturation: 49/100, brightness: 54/100, alpha: 1.0)
rect.strokeColor = UIColor(hue: 215/360, saturation: 49/100, brightness: 54/100, alpha: 1.0)
rect.physicsBody = SKPhysicsBody(rectangleOf: CGSize(width: rect.frame.width, height: rect.frame.height))
rect.physicsBody?.friction = 0.4
rect.physicsBody?.restitution = 0
rect.physicsBody?.mass = 100
rect.physicsBody?.allowsRotation = true
rect.physicsBody?.isDynamic = true
rect.physicsBody?.linearDamping = 0
rect.physicsBody?.angularDamping = 0
//rect.physicsBody?.velocity = CGVector(dx: 0, dy: -700)
rect.physicsBody!.applyImpulse(CGVector(dx: 2.0, dy: -2.0))
rect.lineWidth = 10
addChild(rect)
I am not sure if I am asking the right question but I have the rectangular node falling down unto a paddle that can be moved side to side by touch. Once the rect node is on top of the paddle I want it to stay on it while the I move the paddle but it stays pinned and does not move although everything else (gravity, rotation, etc.) works.
Here are the pictures to clarify