Skip to content

Commit 90c8825

Browse files
committed
A PathFollower with a very short duration would often not end in the correct place, which is the very end of the Path, due to the tween handling the movement not running one final update when the tween was complete. It will now always end at the final point of the path, no matter how short the duration. Fix phaserjs#4950
1 parent d419428 commit 90c8825

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

src/gameobjects/components/PathFollower.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -344,15 +344,24 @@ var PathFollower = {
344344
if (tween)
345345
{
346346
var tweenData = tween.data[0];
347+
var pathVector = this.pathVector;
348+
349+
if (tweenData.state !== TWEEN_CONST.COMPLETE)
350+
{
351+
this.path.getPoint(1, pathVector);
352+
353+
pathVector.add(this.pathOffset);
354+
355+
this.setPosition(pathVector.x, pathVector.y);
347356

348-
if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD)
357+
return;
358+
}
359+
else if (tweenData.state !== TWEEN_CONST.PLAYING_FORWARD && tweenData.state !== TWEEN_CONST.PLAYING_BACKWARD)
349360
{
350361
// If delayed, etc then bail out
351362
return;
352363
}
353364

354-
var pathVector = this.pathVector;
355-
356365
this.path.getPoint(tween.getValue(), pathVector);
357366

358367
pathVector.add(this.pathOffset);

0 commit comments

Comments
 (0)