3

I wasn't sure if this was the correct forums to post this on; I was considering the Game Development site.

I'm developing a game in LibGDX (Java) and I've set up a btKinematicCharacterController to control the player. This handles the jumping, walking, and everything else.

However, I've come across a problem. Imagine that the character is standing on a slope -- even a very gradual one. The character will slowly slide down the slope, which is very annoying for the purpose of my game (and, I imagine, most.) This is because if a player wants to just stand on a slope, they can't.

I think this is happening because of the collision detection resolution. The player may very slightly fall through the floor, and since it's on a slope, would then be pushed out along the normal of the slope. This would mean, simply, they'd be pushed along slightly.

My actual player model is a capsule, and I use a ghost object for the btKinematicCharacterController.

So how can I make sure that my character doesn't slide down slopes? Of course, it needs to still have physics so that it can jump, and collide with other objects.

Jacob Garby
  • 773
  • 7
  • 22

1 Answers1

2

One of the popular approach is to disable gravity when there are >=1 platforms under the character's foot.

It can be done by :-

Another approach is to hard code it (link to a short discussion - 2D Metroid related), but it is a hard work and heavily depend on the stage design.

This video may help. It is Unity, not related to Bullet, but seems applicable.

I am also very interested in this problem. Please don't accept if it doesn't solve.
To reader, if there are better answers, feel free to share.

javaLover
  • 6,347
  • 2
  • 22
  • 67
  • Do you happen to know what `setSensor(true)` is called on? – Jacob Garby May 02 '17 at 16:06
  • @Jacob Garby I am pretty sure that : on a new shape/body attached under the character. .... same concept as http://www.iforce2d.net/b2dtut/jumpability, look for content around this image http://www.iforce2d.net/image/jumpability-player-body.png. (It is Box2D link but applicable.) – javaLover May 03 '17 at 01:54
  • Thanks. I can't test it currently but I'll check this out when I get home in about five hours – Jacob Garby May 03 '17 at 07:28
  • @Jacob Garby Take your time and code it slowly. Bullet's callback is very hard to use, especially if you aim for the highest performance. It may even take several days if this is your first time. – javaLover May 03 '17 at 08:05