0
votes

I'd like to know if there's any way to make a sprite have the same "amount of bouncing" when colliding with other objects in Sprite Kit. I mean, I want it move with the same force after a collision. I have set both colliding objects restitution to 1.0 but after some collisions and in a certain angle, the sprite decelerates.

1
Turn off friction: self.physicsBody?.friction = 0 - Knight0fDragon
@Knight0fDragon nope, its velocity is still decreasing after every collision - Facundo Schiavoni
Did you set it to both the physics world and your node? - Knight0fDragon
Try setting node.physicsBody?.linearDamping = 0 - 0x141E
@0x141E Yep, that worked. Thanks! - Facundo Schiavoni

1 Answers

0
votes

First: Change the gravity of the physics world to zero

self.physicsWorld.gravity = CGVector(dx: 0, dy: 0)

Second: Reduce the body’s linear velocity (LinearDamping)

myBall.physicsBody!.linearDamping = 0

Third: Change the bounciness of the physics body

myBall.physicsBody!.restitution = 0

Fourth: Change the Friction

myBall.physicsBody!.friction = 0

See the whole explanation in the DevelopApps.org website http://www.developapps.org/sprite-kit-tutorial-how-to-make-a-node-keep-bouncing/