# Sprite not staying still

**URL:** <https://phaser.discourse.group/t/sprite-not-staying-still/5029>\
**Category:** Phaser 3\
**Created:** [January 28, 2020, 3:37pm UTC](https://phaser.discourse.group/t/sprite-not-staying-still/5029 "2020-01-28T15:37:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabahat70](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sabahat70](https://phaser.discourse.group/u/sabahat70)\
**Post date:** [January 28, 2020, 3:37pm UTC](https://phaser.discourse.group/t/sprite-not-staying-still/5029/1 "2020-01-28T15:37:36Z")

</div>

In my config object I have physics set to arcade and arcade’s gravity property to y = 300. I also set my Sprite’s gravity using setGravity() function to 300 under the create() function. This causes my Sprite to move slowly towards the right when it should be staying still.  
However, removing the setGravity() function on the Sprite and leaving the gravity setting inside the config object solved the issue.  
I am still curious why it was happening.

---

<div class="post-metadata">

**Author:** ![snowbillr](https://yyz2.discourse-cdn.com/free1/user_avatar/phaser.discourse.group/snowbillr/32/332_2.png) [@snowbillr](https://phaser.discourse.group/u/snowbillr)\
**Post date:** [January 28, 2020, 3:42pm UTC](https://phaser.discourse.group/t/sprite-not-staying-still/5029/2 "2020-01-28T15:42:02Z")

</div>

`setGravity`'s API documentation will be helpful here: [https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Sprite.html#setGravity\_\_anchor](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Sprite.html#setGravity__anchor)

If you’re only passing it one argument, you’re setting its x and y gravity. It sounds like you want to be using probably just the [https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Sprite.html#setGravityY\_\_anchor](https://photonstorm.github.io/phaser3-docs/Phaser.Physics.Arcade.Sprite.html#setGravityY__anchor) function instead?

One thing to remember is that any gravity added to an individual sprite is _added_ to the world’s gravity. So if you set your world to have a y gravity of 300, and you give your sprite a y gravity of 300, your sprite will effectively have a gravity of 600.

---

<div class="post-metadata">

**Author:** ![sabahat70](https://avatars.discourse-cdn.com/v4/letter/s/b5ac83/32.png) [@sabahat70](https://phaser.discourse.group/u/sabahat70)\
**Post date:** [January 28, 2020, 3:47pm UTC](https://phaser.discourse.group/t/sprite-not-staying-still/5029/3 "2020-01-28T15:47:14Z")

</div>

Thank you! It makes a lot of sense now.
