Skip to main content
Version: Phaser v3.88.2

PathFollower

A PathFollower Game Object.

A PathFollower is a Sprite Game Object with some extra helpers to allow it to follow a Path automatically.

Anything you can do with a standard Sprite can be done with this PathFollower, such as animate it, tint it,

scale it and so on.

PathFollowers are bound to a single Path at any one time and can traverse the length of the Path, from start

to finish, forwards or backwards, or from any given point on the Path to its end. They can optionally rotate

to face the direction of the path, be offset from the path coordinates or rotate independently of the Path.

Constructor

new PathFollower(scene, path, x, y, texture, [frame])

Parameters

nametypeoptionaldescription
scenePhaser.SceneNoThe Scene to which this PathFollower belongs.
pathPhaser.Curves.PathNoThe Path this PathFollower is following. It can only follow one Path at a time.
xnumberNoThe horizontal position of this Game Object in the world.
ynumberNoThe vertical position of this Game Object in the world.
texturestring | Phaser.Textures.TextureNoThe key, or instance of the Texture this Game Object will use to render with, as stored in the Texture Manager.
framestring | numberYesAn optional frame from the Texture this Game Object is rendering with.

Scope: static

Extends

Phaser.GameObjects.Sprite
Phaser.GameObjects.Components.PathFollower

Source: src/gameobjects/pathfollower/PathFollower.js#L11
Since: 3.0.0

Inherited Members

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Flip:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.PathFollower:

From Phaser.GameObjects.Components.Pipeline:

From Phaser.GameObjects.Components.PostPipeline:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.TextureCrop:

From Phaser.GameObjects.Components.Tint:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Sprite:


Public Members

pathConfig

pathConfig: Phaser.Types.GameObjects.PathFollower.PathConfig

Description:

Settings for the PathFollower.

Source: src/gameobjects/components/PathFollower.js#L91
Since: 3.0.0


pathDelta

pathDelta: Phaser.Math.Vector2

Description:

The distance the follower has traveled from the previous point to the current one, at the last update.

Source: src/gameobjects/components/PathFollower.js#L73
Since: 3.23.0


pathOffset

pathOffset: Phaser.Math.Vector2

Description:

An additional vector to add to the PathFollowers position, allowing you to offset it from the

Path coordinates.

Source: src/gameobjects/components/PathFollower.js#L54
Since: 3.0.0


pathRotationOffset

pathRotationOffset: number

Description:

If the PathFollower is rotating to match the Path (@see Phaser.GameObjects.PathFollower#rotateToPath)

this value is added to the rotation value. This allows you to rotate objects to a path but control

the angle of the rotation as well.

Source: src/gameobjects/components/PathFollower.js#L42
Since: 3.0.0


pathTween

pathTween: Phaser.Tweens.Tween

Description:

The Tween used for following the Path.

Source: src/gameobjects/components/PathFollower.js#L82
Since: 3.0.0


pathVector

pathVector: Phaser.Math.Vector2

Description:

A Vector2 that stores the current point of the path the follower is on.

Source: src/gameobjects/components/PathFollower.js#L64
Since: 3.0.0


Inherited Methods

From Phaser.Events.EventEmitter:

From Phaser.GameObjects.Components.Alpha:

From Phaser.GameObjects.Components.BlendMode:

From Phaser.GameObjects.Components.Depth:

From Phaser.GameObjects.Components.Flip:

From Phaser.GameObjects.Components.GetBounds:

From Phaser.GameObjects.Components.Mask:

From Phaser.GameObjects.Components.Origin:

From Phaser.GameObjects.Components.PathFollower:

From Phaser.GameObjects.Components.Pipeline:

From Phaser.GameObjects.Components.PostPipeline:

From Phaser.GameObjects.Components.ScrollFactor:

From Phaser.GameObjects.Components.Size:

From Phaser.GameObjects.Components.TextureCrop:

From Phaser.GameObjects.Components.Tint:

From Phaser.GameObjects.Components.Transform:

From Phaser.GameObjects.Components.Visible:

From Phaser.GameObjects.GameObject:

From Phaser.GameObjects.Sprite:


Public Methods

preUpdate

<instance> preUpdate(time, delta)

Description:

Internal update handler that advances this PathFollower along the path.

Called automatically by the Scene step, should not typically be called directly.

Access: protected

Parameters:

nametypeoptionaldescription
timenumberNoThe current timestamp as generated by the Request Animation Frame or SetTimeout.
deltanumberNoThe delta time, in ms, elapsed since the last frame.

Overrides: Phaser.GameObjects.Sprite#preUpdate

Source: src/gameobjects/pathfollower/PathFollower.js#L56
Since: 3.0.0