How to make a sprite sit on a moving sprite and travel with it. I have made the red box jump with impulse and when it falls on the black block down which is moving, the red box stays were it dropped slips the moving object like there is no friction. Conditions gravity on, friction 1.0 in both even tried increasing the mass, but nothing worked. Please give me any details how to make it work ? thanks override func didMoveToView(view: SKView) { /* Setup your scene here */
self.physicsWorld.gravity = CGVectorMake(0.0, -9.8)
SquareOne.fillColor = UIColor.orangeColor()
SquareOne.position = CGPoint(x: self.frame.midX, y: self.frame.midY)
SquareOne.physicsBody = SKPhysicsBody(rectangleOfSize: SquareOne.frame.size)
SquareOne.physicsBody?.friction = 1.0
SquareOne.physicsBody?.restitution = 0.0
addChild(SquareOne)
SquareTwo.fillColor = UIColor.greenColor()
SquareTwo.position = CGPoint(x: self.frame.midX, y: self.frame.midY - 100)
SquareTwo.physicsBody = SKPhysicsBody(rectangleOfSize: SquareTwo.frame.size)
SquareTwo.physicsBody?.dynamic = false
SquareTwo.physicsBody?.affectedByGravity = false
SquareTwo.physicsBody?.friction = 1.0
SquareTwo.physicsBody?.restitution = 0.0
addChild(SquareTwo)
}
override func touchesBegan(touches: Set<NSObject>, withEvent event: UIEvent) {
/* Called when a touch begins */
for touch in (touches as! Set<UITouch>) {
let location = touch.locationInNode(self)
SquareTwo.runAction(SKAction.moveByX(-100, y: 0.0, duration: 3.0))
}
}