Better way to implement a character controller?

Post Reply
GoldBoa
Posts: 1
Joined: Sun Oct 23, 2016 6:47 am

Better way to implement a character controller?

Post 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.
Tau
Posts: 25
Joined: Tue May 01, 2012 11:52 am

Re: Better way to implement a character controller?

Post by Tau »

Make your own, that's what i did. I just couldn't use Bullets.

https://www.youtube.com/watch?v=bITTsHFVZn0
avithohol
Posts: 34
Joined: Sun Feb 12, 2017 10:22 am

Re: Better way to implement a character controller?

Post 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.
hyyou
Posts: 96
Joined: Wed Mar 16, 2016 10:11 am

Re: Better way to implement a character controller?

Post 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)
Post Reply