Change height of capsule at runtime
Posted: Mon Dec 14, 2009 9:26 am
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
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