Sprite not staying still

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.

setGravity's API documentation will be helpful here: 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 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.

Thank you! It makes a lot of sense now.