Phaser API Documentation

  Version: 
setSlideFactor(x, [y])

Description:

Sets the Slide Factor of this Body.

The Slide Factor controls how much velocity is preserved when this Body is pushed by another Body.

The default value is 1, which means that it will take on all velocity given in the push. You can adjust this value to control how much velocity is retained by this Body when the push ends.

A value of 0, for example, will allow this Body to be pushed but then remain completely still after the push ends, such as you see in a game like Sokoban.

Or you can set a mid-point, such as 0.25 which will allow it to keep 25% of the original velocity when the push ends. You can combine this with the setDrag() method to create deceleration.

Parameters:

name type arguments Default description
x number

The horizontal slide factor. A value between 0 and 1.

y number <optional> x

The vertical slide factor. A value between 0 and 1.

Returns:
Description:

This Body object.

Since: 3.70.0