# physics.body.isMoving doesnt get update from .moveTo or .moveToObject

**URL:** <https://phaser.discourse.group/t/physics-body-ismoving-doesnt-get-update-from-moveto-or-movetoobject/1426>\
**Category:** Phaser 3\
**Created:** [February 27, 2019, 5:50am UTC](https://phaser.discourse.group/t/physics-body-ismoving-doesnt-get-update-from-moveto-or-movetoobject/1426 "2019-02-27T05:50:16Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 27, 2019, 5:50am UTC](https://phaser.discourse.group/t/physics-body-ismoving-doesnt-get-update-from-moveto-or-movetoobject/1426/1 "2019-02-27T05:50:16Z")

</div>

Post is about this topic:  
[https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html#isMoving\_\_anchor](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Body.html#isMoving__anchor)

I tried testing it in my own game and its not getting updated from neither moveTo or moveToObject methods. Am I calling this incorrectly?

I tried modifying a text object in the labs to see and output it to screen here:  
[https://labs.phaser.io/edit.html?src=src\physics\arcade\move%20and%20stop%20at%20position.js](https://labs.phaser.io/edit.html?src=src%5Cphysics%5Carcade%5Cmove%20and%20stop%20at%20position.js)

full code (with moveTo as call):

```
var config = {
    type: Phaser.AUTO,
    width: 800,
    height: 600,
    parent: 'phaser-example',
    physics: {
        default: 'arcade'
    },
    scene: {
        preload: preload,
        create: create,
        update: update
    }
};  

var debug;
var source;
var target = new Phaser.Math.Vector2();
var distanceText;
var isMoving;

new Phaser.Game(config);

function preload ()
{
    this.load.image('flower', 'assets/sprites/flower-exo.png');
}

function create ()
{
    source = this.physics.add.image(100, 300, 'flower');

    debug = this.add.graphics();

    this.input.on('pointerdown', function (pointer) {

        target.x = pointer.x;
        target.y = pointer.y;
        
        // Move at 200 px/s:
        this.physics.moveTo(source, target.x, target.y, 200);

        debug.clear().lineStyle(1, 0x00ff00);
        debug.lineBetween(0, target.y, 800, target.y);
        debug.lineBetween(target.x, 0, target.x, 600);

    }, this);
    ismoving = this.add.text(40, 40, 'ismoving: false');
    distanceText = this.add.text(10, 10, 'Click to set target', { fill: '#00ff00' });
}

function update ()
{
    var distance = Phaser.Math.Distance.Between(source.x, source.y, target.x, target.y);

    if (source.body.speed > 0)
    {
        distanceText.setText('Distance: ' + distance);
        ismoving.setText('ismoving: ' + source.body.isMoving)
        // 4 is our distance tolerance, i.e. how close the source can get to the target
        // before it is considered as being there. The faster it moves, the more tolerance is required.
        if (distance < 4)
        {
            source.body.reset(target.x, target.y);
        }
    }
}
```

---

<div class="post-metadata">

**Author:** ![jjcapellan](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/jjcapellan/32/542_2.png) [@jjcapellan](https://phaser.discourse.group/u/jjcapellan)\
**Post date:** [February 27, 2019, 10:31am UTC](https://phaser.discourse.group/t/physics-body-ismoving-doesnt-get-update-from-moveto-or-movetoobject/1426/2 "2019-02-27T10:31:19Z")

</div>

Looking at the Phaser code, it seems that **isMoving** is not yet implemented (correct me if I’m wrong.).  
A possible solution would be to use something like:

```javascript
var ismoving = (source.body.deltaAbsX() > 0 || source.body.deltaAbsY() > 0);

```

Or the most obvious but not always reliable:

```javascript
var ismoving = (source.body.velocity.x != 0 || source.velocity.y != 0);

```

Regards.

---

<div class="post-metadata">

**Author:** ![aylictal](https://avatars.discourse-cdn.com/v4/letter/a/ac91a4/32.png) [@aylictal](https://phaser.discourse.group/u/aylictal)\
**Post date:** [February 27, 2019, 3:25pm UTC](https://phaser.discourse.group/t/physics-body-ismoving-doesnt-get-update-from-moveto-or-movetoobject/1426/3 "2019-02-27T15:25:33Z")

</div>

I used a simple boolean for my case as the moveto command was being used in a timed event. Was still surprising though when it wasn’t working and had to dig through some async code to figure out why a condition wasn’t being met ☹

---

<div class="post-metadata">

**Author:** ![samme](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/samme/32/5275_2.png) [@samme](https://phaser.discourse.group/u/samme)\
**Post date:** [February 27, 2019, 9:29pm UTC](https://phaser.discourse.group/t/physics-body-ismoving-doesnt-get-update-from-moveto-or-movetoobject/1426/5 "2019-02-27T21:29:18Z")

</div>

I think that property is just left over from Phaser 2 (which has `moveTo()` and `moveFrom()` methods).
