Page 1 of 1

Better way to implement a character controller?

Posted: Tue Nov 28, 2017 3:59 pm
by GoldBoa
Hello,

Recently I've been trying to create a character controller with bullet. Currently what I've got right now is a capsule lifted by a small raytrace. Every update I move the capsule, resolve collisions, raytrace downwards from the capsule and lift it based on that. This works well enough except for the common problem of small but deep holes not working well with it but also not being able to climb up steep slopes as the capsule ends up colliding with the slope before it can move into a position where the raycast hits it. I was wondering what a better solution for this would be for this. I was considering just doing a few more ray casts but this sounds pretty hacky. I've also tried going through the btKinematicCharacterController source but I'm having a hard time trying to understand what's going on.

Thanks.

Re: Better way to implement a character controller?

Posted: Sat Dec 16, 2017 9:36 am
by Tau
Make your own, that's what i did. I just couldn't use Bullets.

https://www.youtube.com/watch?v=bITTsHFVZn0

Re: Better way to implement a character controller?

Posted: Mon Jan 22, 2018 7:46 pm
by avithohol
I think your solution is good, but continue. Set zero or small friction for the capsule, it will slide like a soap, and will let you climb stairs. I dont use kinematic body just a standard rigidbody, which i push around with force.
If you have issue that the body slide too far then use setdamp when its on the ground. Use raycast to determine if you are on the ground.

Re: Better way to implement a character controller?

Posted: Wed Jan 24, 2018 11:29 am
by hyyou
I am another one that hate ray-cast for foot-test.

Adding another "foot" btRigidBody as sensor works for me.
http://www.bulletphysics.org/mediawiki- ... s#Triggers
I didn't claim that the sensor approach is better, though.

If you are interested, please see related Box2D's concept at http://www.iforce2d.net/b2dtut/jumpability. (see the second image)
However, it is pretty tricky (but possible) to implement such thing in Bullet, because btCompoundShape can't contain sensor.
Related link : btCompoundShape with a non-dynamic child as a sensor
I ended up encapsulating Bullet to make it supports "compound-body that has a sensor child" manually. (angry face)