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

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.