I've searched this one and I think there must be some parameter to fix this but I haven't found it.
I have a scene in SpriteKit where I want some circles/balls to bounce around and maintain any velocity they have indefinitely. They should bounce off the edges of the scene.
This is working if they are moving fast enough, or hit at a fairly sharp angle, but if they are going slower and coming in close to the plane of the edge, they keep moving (which is good) but they "Stick" to the edges. This sticking is what I don't want. They should rebound even if going very slowly.
To set up the edges, I used:
SKPhysicsBody *borderBody = [SKPhysicsBody bodyWithEdgeLoopFromRect:self.frame];
self.physicsBody = borderBody;
self.physicsBody.friction = 0.0;
self.physicsBody.restitution = 1.0;
self.physicsBody.linerDamping = 0.0;
self.physicsBody.angularDamping = 0.0;
self.physicsBody.affectedByGravity = NO;
And on the circle nodes, I have similar settings, like:
ball.usesPresciseCollisionDetection = YES;
ball.dynamic = YES;
ball.restitution = 1.0;
ball.linearDamping = 0.0;
ball.angularDamping = 0.0;
ball.friction = 0.0;
I have the gravity in my scene at zero. I add an impulse to the nodes and they start bouncing- It seems very close, as things bounce around, but then if there are any that are moving slowly and come in at a shallow angle, they "hug" the edges. I'll try including an illustration below to help visualize.
http://i.imgur.com/Rpr7luY.png
I've tried playing with lots of the PhysicsBody settings, but can't get things to stop sticking.
Thanks!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…