The character walks like a drunk

Hello everyone. Testing physics. My task is to make the character collide with walls and be subject to gravity. I achieved this by using Ammo, but the character wobbles like a drunk and sometimes falls :laughing: What is the best option to make a wasd walk for the character to walk without falling?

https://playground.babylonjs.com/#6WL6G2#1

Adding @Cedric

1 Like

Hi @Nawar

You can disable Angular Factor for other axis than Y.

Drink Walk | Babylon.js Playground

Check line 31

5 Likes

Thank you. Before you leave, can you tell me why when the character approaches the wall, everything starts to lag? Why is this happening and what are the options for solving this problem?

https://playground.babylonjs.com/#6WL6G2#3

I’m getting some Odd 404 code when you run into the wall for the first time no clue what that is about.

^ohh Cedric beat me to this, dang maybe I should read.

1 Like

@Cedric would definitely know more about this, but if you look at the inspector the frame time for calculating physics skyrockets when you walk into a wall. It’s probably because both objects use mesh impostors and the geometry might be a bit too complex for that. Try replacing them with simpler impostors like this:

https://playground.babylonjs.com/#6WL6G2#11

Notice in the player mesh callback there’s some new code for loading a box impostor.

1 Like

Thanks for the help. Now, all I wanted to know, I found out

I’m no bone doctor, but I have some concerns about this fellow…

Not sure if that has anything to do with it or not :open_mouth:

1 Like