^^^^^ 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:
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.
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.
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.