Gravity not working?

^^^^^ is pretty much the most basic code to implement gravity according to the docs (Camera Collisions | Babylon.js Documentation). And the gravity is not working. Same is the issue in my project, but my older projects somehow have gravity working. I might be missing something obvious perhaps as I came back to babylon after a while, so I am not sure if this goes in bugs or question category, bugs felt more appropriate but I found it hard to believe that something as basic as gravity would be bugged so I concluded I might be missing something. I have been looking at this for a couple of hours now and I require the wisdom of the forums. Thank you all very much.

It seems to me that you need:

    camera._needMoveForGravity = true; // to fall by gravity even if no camera movement
    camera.checkCollisions = true;

The full PG:

1 Like

I can see that it does fix my issue, but in typescript, it gives an error for that property being private. What would be a better way to do it then? Also, is the property name contradictory? And, why is this not mentioned in the docs, were there some assumptions made that I should be aware of?

I think checkCollisions=true is the important parameter, but I donā€™t know why we donā€™t fall until we hit the ground when we move the cameraā€¦ It looks like weā€™re falling a little but stopping too soonā€¦

cc @Cedric in case we would know.

1 Like

Iā€™ve checked the forum for older posts related as I remember itā€™s not the first time having an issue with gravity only being applied when moving.
Itā€™s always the same fix with _needMoveForGravity. Iā€™ll do a PR today to have a public member instead.

1 Like
2 Likes

On my local setup, checkCollisions=true, doesnā€™t help either. I had a console.log inside engine.render logging out cameraā€™s position, and there was no moment, not even in the initial couple of frames.

Thank you. Iā€™ll just ignore typescript for now and mark @Takemura as solution. Hope for the prā€™s speedy implementation.