Hello guys, when i try to move through between 2 boxes and keep pressing forward, camera is vibrating. Is there any solution for this? I expect camera to stand still
That’s a tough one
You are trying to collide against one box, so the collider moves you to the other side, and then, one frame after, the collider correct back, because you collide with the other box. and this will go on until you stop moving forward.
What you can do is check for your keyboard input yourself, and check against what element you are collided. Having said that, since you are also colliding constantly against the floor (you are “walking” on it) it is not so trivial.
Hmm, if you reduce the width of the camera’s collision body from 0.5 to 0.3, that seems to fix the vibrating issue: https://playground.babylonjs.com/#4HUQQ#1607
Alternatively, making the gap between the barrels larger helps reduce the amount of vibration as well.
So maybe it’s a matter of avoiding the edge cases where the size of camera.ellipsoid is too close to the size of the gap between objects…
Thanks for the reply, unfortunately this is not a solution for my case. In my project there are several gaps like this and the gap sizes are different from each other
Thanks for the reply. What am I going do with that input and collusion information? Could you drop a PG sir?
Similar topic, https://playground.babylonjs.com/#4HUQQ#1610
If you try to move on the box below(like staircase), camera vibrates. In my case, camera shouldn’t move above the staircase and shouldn’t vibrate. You can change the gravity. I tried fixed “camera.position.y” to a constant in “scene.registerBeforeRender” function but still vibrates
It has a lot to do with your overall character and scene definition. The gravity, the size of the step, the ellipsoid.
Change your ellipsoid to something larger than 1 on the y axis (try 1.2 or 1.3 for example), you will see that you climb the step. The entire scene is “right on the threshold”, so it continuously tries to climb up and then gravity takes it down. You could also lower the gravity, make a slightly smaller step, or increase the camera’s movement speed. All of those factors will influence collision one way or the other. And you will need to adjust them to your needs, of course.