ThomasCle
ThomasCle

Reputation: 6801

Applied force keeps the node moving

I am creating a top-down game of pool. The entire view is the table, and then I have number of ball-nodes. When I apply force to the balls, they keep moving for quite long time, where I'd like the force to wear off faster. Since I haven't been working too much with physics before I am having a difficult time figuring out which propert(y/ies) to adjust.

I have a quite high restitution (0.8) on the balls, because I want them to bounce off the edges. The edges are defined by this node:

SKPhysicsBody(edgeLoopFrom: CGRect(x: -self.size.width/2.0, y: -self.size.height/2.0, width: self.size.width, height: self.size.height))

I see that there is a friction property on the SKShapeNode class. I am feeling that it might be the right one to use, but it doesn't seem to help when I turn it up.

So what is the right approach - how do I make the applied force wear off faster?

Upvotes: 2

Views: 50

Answers (1)

0x141E
0x141E

Reputation: 12753

Adjusting the physics body's linearDamping property will allow you to change the rate at which the body slows over time (linearDamping doc). The value should be between 0 and 1.0, where 0 results in no damping and 1 provides maximum damping (slows faster).

Upvotes: 2

Related Questions