Search code examples
iosobjective-csprite-kitgame-physics

How can you measure the weight or pressure being applied to an SKSpriteNode?


I know that you can define a sprite's mass and density with SpriteKit. If I had 2 sprites laying on top of a 3rd sprite, like a scale, is there a way to measure the total weight that is lying on the 3rd node?


Solution

  • Sure. Just define your own gravity in the z direction, multiply it by the mass of the node on top, and you've got its weight. No need to take density into account (it's not like my scale says I weigh any different if I stand on it or lay down on it). Pressure is force/area, so just divide the weight by the area if you want to get that.