The PhysicsBody component manages the Game Objects physics body and physics enabling. It also overrides the x and y properties, ensuring that any manual adjustment of them is reflected in the physics body itself.
bodyis the Game Objects physics body. Once a Game Object is enabled for physics you access all associated properties and methods via it.
By default Game Objects won't add themselves to any physics system and their
bodyproperty will be
To enable this Game Object for physics you need to call
objectis this object and
systemis the Physics system you are using. If none is given it defaults to
You can alternatively call
game.physics.arcade.enable(object), or add this Game Object to a physics enabled Group.
Important: Enabling a Game Object for P2 or Ninja physics will automatically set its
anchorproperty to 0.5, so the physics body is centered on the Game Object.
If you need a different result then adjust or re-create the Body shape offsets manually or reset the anchor after enabling physics.
The position of the Game Object on the x axis relative to the local coordinates of the parent.
The position of the Game Object on the y axis relative to the local coordinates of the parent.
The PhysicsBody component postUpdate handler. Called automatically by the Game Object.
The PhysicsBody component preUpdate handler. Called automatically by the Game Object.