apple developer

home tech_notes app_store github stackoverflow devto

Configuring a Physics Body

Move a physics body, and make it collide with other objects, by setting its physical properties once or changing them dynamically.


You configure mass, area and density to values that create the right level of momentum and transfer of kinetic energy upon collisions of your in-game objects. Though you typically configure a physics body only once, there are exceptions; for example, when a node crosses into a different environment, such as land to space, or land to water.

Use Mass to Resist Acceleration

You set the mass on every volume-based body in your scene so that it properly reacts to forces applied to it.

A physics body’s mass, area, and density properties are all interrelated. When you first create a body, the body’s area is calculated, and never changes afterward. The other two properties change values at the same time, based on the following formula:

mass = density x area

When you configure a physics body, you have two options:

Time Your Changes to a Physics Body’s Properties

Most often, you configure a physics body once and then never change it. For example, the mass of a body is unlikely to change during play. However, you are not restricted from changing it. Some kinds of games may require the ability to adjust a body’s properties even while the simulation is executing. Here are a few examples of when you might do so:

Typically, you make these changes as part of scene pre- and post-processing, using the SKSceneDelegate methods.

download this page as .md

download this page as .pdf

back to SpriteKit documentation