# Why is my player still moving down when I set its gravity to 0?

I'm writing Lode Runner like platformer game. I'm trying to solve player sprite slowly moving down when on ladder by setting player.body.gravity.y = 0. I have arcade physics gravity y set to 900 in game config. But game gravity settings seems to override player.body.gravity settings.

I even log player.body.gravity.y to console. It shows 0 when player is on ladder. But it still slowly moving down.

According to this documentation page, it looks like the total gravity for a body is the one you set the way you did for your body, added to the global gravity:

gravity :Phaser.Math.Vector2

Acceleration due to gravity (specific to this Body), in pixels per second squared. Total gravity is the sum of this vector and the simulation's gravity.

I haven't worked with Phaser 3, but I guess that, since the total gravity is a sum of values, you'd want to set the gravity for your player to -900 to counteract the effect of the gravity.

Alternatively, if you just want to disable the gravity for your object, it looks like you could do it through the setAllowGravity(true/false) function, as described here.

As an example, you can take a look at this sandbox, setting the gravity to -60 at line 38 will make the second box stay still.

• platformergametest.000webhostapp.com here's the game I hosted on free hosting. Can you check why is my player is freezed on the top ladder (appers when collected all chests) ? Sometimes I'm able to climb and sometimes not. Also when I get to the top of the ladder player is still jumping a little bit. I have no idea how to fix it. And if I set gravity to -900 while on ladder I'm not able to go left and right when I reach the top. I think I made some foundamental mistake in the conception of control management. Sorry for asking too many questions but I don't want to make new post Jul 8, 2019 at 22:01
• @Madcap This appears to be a different question. Comments are not a great place to ask new questions ao I suggest you create a new question post including the code you've used. Jul 8, 2019 at 23:32
• Thanks again! How to mark my question answered and close the topic ? Jul 9, 2019 at 13:51
• @Madcap Below the up-down arrows, there should be a greyed out check-mark. Clicking this will mark this answer as "Accepted", which will indicate to other visitors that this one was the most helpful in solving your issue. You don't have to do this, but it's useful for future users. Also, the "closed" status is for questions that are considered off-topic for this site. Your question being on topic here, it does not need to be "closed"; the "accepted" status will be more than enough :) Jul 9, 2019 at 13:59