# Wrong behaviour with staticbody and various scale

**URL:** <https://phaser.discourse.group/t/wrong-behaviour-with-staticbody-and-various-scale/7974>\
**Category:** Phaser 3\
**Created:** [October 28, 2020, 7:10pm UTC](https://phaser.discourse.group/t/wrong-behaviour-with-staticbody-and-various-scale/7974 "2020-10-28T19:10:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [October 28, 2020, 7:10pm UTC](https://phaser.discourse.group/t/wrong-behaviour-with-staticbody-and-various-scale/7974/1 "2020-10-28T19:10:01Z")

</div>

Hi,

I made this simple jsfiddle to explain my problem :

> **[Edit fiddle - JSFiddle - Code Playground](https://jsfiddle.net/espace3d/69wzphn1/1/)**

When you set various scale to static body, the size of the body is not equal to the size of the sprite.

How do you fix that ? (setOrigin si well on .5 and normally the size of the body adjust automatically the size of the sprite ???).

Thanks a lot.

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

var sprite;
var group;

var game = new Phaser.Game(config);

function preload() {
    this.load.image('mushroom', 'assets/sprites/mushroom2.png');
    this.load.image('ball', 'assets/sprites/shinyball.png');
}

function create() {
    sprite = this.physics.add.image(400, 300, 'mushroom');

    group = this.physics.add.staticGroup({
        key: 'ball',
        frameQuantity: 30,
        scale: Math.random(1, 4)
    });

    group.children.each(function (sprite) {
        sprite.setScale(Math.random(3, 8));
        sprite.setOrigin(.5)
    }, this);
 

    Phaser.Actions.PlaceOnRectangle(group.getChildren(), new Phaser.Geom.Rectangle(84, 84, 616, 416));

    group.refresh();

    sprite.setVelocity(100, 200).setBounce(1, 1).setCollideWorldBounds(true).setGravityY(200);

    this.physics.add.collider(sprite, group);
}
```

---

<div class="post-metadata">

**Author:** ![espace](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/espace/32/1405_2.png) [@espace](https://phaser.discourse.group/u/espace)\
**Post date:** [October 28, 2020, 7:25pm UTC](https://phaser.discourse.group/t/wrong-behaviour-with-staticbody-and-various-scale/7974/2 "2020-10-28T19:25:40Z")

</div>

sorry for this ridiculous question find by myself :

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

var sprite;
var group;

var game = new Phaser.Game(config);

function preload() {
    this.load.image('mushroom', 'assets/sprites/mushroom2.png');
    this.load.image('ball', 'assets/sprites/shinyball.png');
}

function create() {
    sprite = this.physics.add.image(400, 300, 'mushroom');

    group = this.physics.add.staticGroup({
        key: 'ball',
        frameQuantity: 30,
        scale: Math.random(1, 4)
    });

    group.children.each(function (sprite) {
        sprite.setScale(Math.random(3, 8));
        sprite.setSize(sprite.displayWidth, sprite.displayHeight)
    });

    Phaser.Actions.PlaceOnRectangle(group.getChildren(), new Phaser.Geom.Rectangle(84, 84, 616, 416));

    group.refresh();

    sprite.setVelocity(100, 200).setBounce(1, 1).setCollideWorldBounds(true).setGravityY(200);

    this.physics.add.collider(sprite, group);
}
```

---

<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:** [October 28, 2020, 9:03pm UTC](https://phaser.discourse.group/t/wrong-behaviour-with-staticbody-and-various-scale/7974/3 "2020-10-28T21:03:28Z")

</div>

[StaticGroup#refresh](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.StaticGroup.html#refresh) doesn’t resize bodies. You can use [refreshBody](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Components.Enable.html#refreshBody) for that.

[https://jsfiddle.net/hckm0L2j/1/](https://jsfiddle.net/hckm0L2j/1/)
