1
votes

I am having a problem over here. I am using SKSpriteNode for creating different objects in world. And I have applied gravity self i.e. SkScene.

So, the problem here is when I create a SKSPriteNode and give mass to its physics body then it behaves similar for everytime. For example:

If I put mass as 0 then also its falls down (it should not because mass is zero, so according to physics rule body should not fall down with mass 0).

Now, if I change mass to 10 or 100 or even 1000 it falls down with the same speed as it is with 0 mass.

Is there any one with same issue? Or can anyone help me with this?

3

3 Answers

7
votes

Just Newtonian physics, I reckon - acceleration due to gravity is independent of the mass of the object. The gravitational force is proportional to the mass, but not the acceleration.

The zero mass case is weird, but it's probably just a convention of the physics engine. I'd guess that it doesn't look at mass at all during those calculations. Mass becomes useful when dealing with other interactions e.g. collisions or springs.

1
votes

Though mass does not affect gravity (as people have so vehemently pointed out), I am guessing you are trying to make the gravity have a variable effect on different types of nodes in your project.

You can achieve the same by tweaking the SKPhysicsBody's friction, linearDamping or angularDamping values.

0
votes

In case anyone stumbles over it.. To disable gravity for certain sprites use

physicsBody.affectedByGravity = false