I wanted to create a bouncy box. Something like a jelly, where anything that hits it will also bounce. I tried physicsBody.restitution
but it doesn't work because it seems to be the bounciness of an object if it hits another object. But what I want is the bounciness if it gets hit by an object.
Was looking through the docs and didn't find anything. Anyone has any idea on making something like this?
I currently have a ball and a block (pong game) for practice, I want the ball to bounce a little faster each time it hits a block. So I added a restitution
of 1.02
to the ball. Is that right?
_ball.physicsBody = [SKPhysicsBody bodyWithPolygonFromPath:ballPath];
_ball.physicsBody.friction = 0.f;
_ball.physicsBody.restitution = 1.02f;
_ball.physicsBody.linearDamping = 0.f;
_ball.physicsBody.allowsRotation = NO;
_ball.physicsBody.affectedByGravity = NO;
I also have blocks that are supposed to be hit by the ball and these blocks are jelly so it should bounce harder, but adding restitution to it doesn't change anything on the scene.
_block.physicsBody = [SKPhysicsBody bodyWithRectangleOfSize:_block.size];
_block.physicsBody.friction = 0.f;
_block.physicsBody.restitution = 0.f;