You’re reading the docs for Phaser v3.88.2. The latest is Phaser v4.1.0.

Phaser.Physics.Matter.Components.Velocity

Scope: static

Source: src/physics/matter-js/components/Velocity.js#L9
Since: 3.0.0

Static functions

getAngularSpeed

instancegetAngularSpeed()

Description:

Gets the current rotational speed of the body.

Equivalent to the magnitude of its angular velocity.

Returns: number - The current angular velocity of the body.

Source: src/physics/matter-js/components/Velocity.js#L137
Since: 3.60.0


getAngularVelocity

instancegetAngularVelocity()

Description:

Gets the current rotational velocity of the body.

Returns: number - The current angular velocity of the body.

Source: src/physics/matter-js/components/Velocity.js#L106
Since: 3.60.0


getVelocity

instancegetVelocity()

Description:

Gets the current linear velocity of the physics body.

Returns: Phaser.Types.Math.Vector2Like - The current linear velocity of the body.

Source: src/physics/matter-js/components/Velocity.js#L75
Since: 3.60.0


setAngularSpeed

instancesetAngularSpeed(speed)

Description:

Sets the current rotational speed of the body.

Direction is maintained. Affects body angular velocity.

Parameters:

nametypeoptionaldescription
speednumberNoThe angular speed.

Returns: Phaser.Physics.Matter.Components.Velocity - This Game Object instance.

Source: src/physics/matter-js/components/Velocity.js#L119
Since: 3.60.0


setAngularVelocity

instancesetAngularVelocity(velocity)

Description:

Sets the angular velocity of the body instantly.

Position, angle, force etc. are unchanged.

Parameters:

nametypeoptionaldescription
velocitynumberNoThe angular velocity.

Returns: Phaser.Physics.Matter.Components.Velocity - This Game Object instance.

Source: src/physics/matter-js/components/Velocity.js#L88
Since: 3.0.0


setVelocity

instancesetVelocity(x, [y])

Description:

Sets both the horizontal and vertical velocity of the physics body.

Parameters:

nametypeoptionaldefaultdescription
xnumberNoThe horizontal velocity value.
ynumberYes"x"The vertical velocity value, it can be either positive or negative. If not given, it will be the same as the x value.

Returns: Phaser.Physics.Matter.Components.Velocity - This Game Object instance.

Source: src/physics/matter-js/components/Velocity.js#L55
Since: 3.0.0


setVelocityX

instancesetVelocityX(x)

Description:

Sets the horizontal velocity of the physics body.

Parameters:

nametypeoptionaldescription
xnumberNoThe horizontal velocity value.

Returns: Phaser.Physics.Matter.Components.Velocity - This Game Object instance.

Source: src/physics/matter-js/components/Velocity.js#L17
Since: 3.0.0


setVelocityY

instancesetVelocityY(y)

Description:

Sets vertical velocity of the physics body.

Parameters:

nametypeoptionaldescription
ynumberNoThe vertical velocity value.

Returns: Phaser.Physics.Matter.Components.Velocity - This Game Object instance.

Source: src/physics/matter-js/components/Velocity.js#L36
Since: 3.0.0