Change height of capsule at runtime

JeDi
Posts: 1
Joined: Mon Nov 17, 2008 6:04 pm

Change height of capsule at runtime

Post by JeDi »

Hi,

We have implemented our own physical movement system using a capsule rigid body with a lot of damping and friction, and it behaves very well. The physics simulation gives us all we need: sliding along walls, steps and slopes, ...

The system also allows to switch between different movement modes: fly mode (without gravity, local axis movement), helicopter mode (also without gravity, but with global up/down movement so you can easily look down and still move forward/backward in the same height layer) and walk mode (with gravity). Everything works perfectly, but I want the capsule to be a sphere when in fly or helicopter mode. I can't seem to find the documentation on how to do this, nor a post in the forum with the same issue.

I am thinking about different things:
- change the height of the capsule to zero, but I can't find a way to do this after creating the shape
- use setLocalScaling to non-uniformily scale over the Y axis. Is this supported in a CapsuleShape?
- use a MultiSphereShape with two spheres. The documentation sais the spheres can be animated individually, but I can't find out how to actually do that. If this is possible, I can move the spheres together when transitioning between modes

The ideal solution of course would be that I can just change the height of the capsule dynamically. If anyone knows how to do that (or any of the other things above), that would be great!

On another note, I am wondering why anyone would use the CharacterController class, which seems to re-implement a lot of things a dynamic body would provide automatically. The only thing I can think of is jumping, which isn't implemented yet in the controller code, and which can very easily be added to a dynamic body using an upwards impulse and some clever ray shooting to determine whether a jump is possible or not.

Greetings,
JeDi
pico
Posts: 229
Joined: Sun Sep 30, 2007 7:58 am

Re: Change height of capsule at runtime

Post by pico »

Hi,

there is an issue in Bullet which doesnt let you change local scale of cylinders and capsules after creation.
http://code.google.com/p/bullet/issues/detail?id=178

A custom character controller is needed for many reasons. Here are some:

*don't get stuck on triangle edges
*climbing stairs with your avator
*avator stay/slip depending on normal
*avator recover from penetration without adding impulses
*avator local velocity
*elevators that make your avatar stick to them
etc