.sleep but with rotation

Hi!

Simple question, but I’m not sure if it is possible.

So the .sleep thing for physics impostors, I’m using them to prevent stuff from moving on slopes. But, the .sleep locks rotation and translation, and I need the rotation to work.

Is it possible to do .sleep with rotation still being possible?

Thanks for any help,

Givo

Do you have a playground available? Could you try not using sleep but instead manually update any properties you need to stay constant in onBeforeRenderObservable? In this example it seems to work https://playground.babylonjs.com/#7149G4#34 but Im not sure how that might impact movement on a slope.

Here is my “game” https://www.babylonjs-playground.com/#IFN77Q#50.

WASD - move
Mouse - look
Space - jump

When not moving, you can’t look left or right because of .sleep. The little console box shows your current linear velocity. The little box underneath tracks if you are inair or not (it’s a variable)

This is a custom player controller as the camera ellipsoid would be had to make jump and slides down slopes. The plan is the when not moving on the slope, you wont slide down.

Ever played CS:GO? Or any FPS ever? You don’t slide down slopes unless if they are too steep that is what I’m trying to make. Here is a helpful video about CS:GO. Some things are irrelevant, but see how source handels objects? If short enough, you teleport to the top of the object. See how smooth the movement is on slopes/stair clipping? That’s my goal.

Any help is appreciated. Hope this helps.

Givo

Cool, it does seem like this is something that is hard to behave exactly as desired as there are similar threads online for all physics engines.

You could try taking a look at this, physics - bullet character controller sliding down any slope gradient - Game Development Stack Exchange which turns gravity off when on the ground to avoid sliding

This also project looks to be using cannon to get character movement working (still suffers from not sticking to ground when hitting the top of a ramp but feels ok)

You could also avoid a physics engine and do raycasts instead and check the normal of the surface you land on to determine how to move the character.

Thanks for the ideas. Turning off the gravity was one thing I had actually tried. the problem was that the player hitbox was a “sphere” (a cube called “sphere”) and when on the slope, gravity would be off, as I would have onoverlap (not exact syntax) for another cube (called “sphere1”) the was bigger than sphere by 0.1, and had no physicsimpostor attached to it. and whenever it was overlapping the slope, if you turned, you would rotate to face down hill. The sphere would be in would be like it was going up an invisible hill.

After a quick search https://www.babylonjs-playground.com/#IFN77Q#26 was the version that I did that in. Yes, it is a sphere. but the physics impostor is a cube. so change the mech to a cube and see what happens. In version #26, left-right look wasn’t done yet (left-right moves the physimpostor, up-down moves the freecamera)

WASD move
mouse look up/down
q/e look left/right
space jump

Thanks for the help!

Givo