BetterCharacterControl in the works

Hey,

as many people get desperate over the internal bullet character, which is just a simple implementation and doesn’t really work like the rest of the bullet physics I started creating a new “BetterCharacterControl” to counter some of the issues people have. This is something that can already be implemented but many people seem to struggle to do so hence I’ll implement it and also make it easily extensible.

Features:

  • Capsule based character like the current character (no rotation per se)
  • Based on a real RigidBody with actual normal gravity
  • RigidBody is not affected by angular forces
  • Uses a RayTest to check if its on the ground
  • Can duck
  • Uses ray test to see if it can unduck
  • External physics forces get applied as normal with a selectable damping value for forces that are not in the gravity direction
  • Has no strange settings like stepHeight, fallSpeed or any such nonsense :wink:
  • If you combine this character with a RagDollControl you can have a character that will push away stuff with the rag doll and its animations but sill behave like a character and bounce into walls, fall etc. due to the capsule.
  • Adapts to the gravity direction automatically and realigns itself (!)
    This is actually impossible due to math :smiley: The character will keep a local coordinate system and “z-forward” so you can gradually change the gravity and it will adapt its coordinate system and the player keeps sensible control over the character. As you see in the second video I can run around the planet while keeping the normal left/right/strafe controls all the time.

It’ll still take me some time to clean this up, add serialization etc. and make it available but as the character questions keep popping up (though they all have been answered already) I guess I thought I let you know whats cooking Available now in svn :wink:

Note: The jerky movement in the second video is due to the recording

Cheers,
Normen

18 Likes
@normen said: Features: - Capsule based character like the current character (no rotation per se)

Hey @normen I chanced upon your post. I am currently needing a Capsule vs Mesh collision model ( for haptic manipulation ). I thought there was no capsule collision model implemented in jME? Is the model you are using new? Or is it already implemented in jME or bullet?

Cheers!

NiHal

@nihal said: Hey @normen I chanced upon your post. I am currently needing a Capsule vs Mesh collision model ( for haptic manipulation ). I thought there was no capsule collision model implemented in jME? Is the model you are using new? Or is it already implemented in jME or bullet?

Cheers!

NiHal


As said in the post, all of this is possible with the current API.
The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless theres emotes that hint otherwise or theres an increased use of exclamation marks and all-capital words.

@normen said: As said in the post, all of this is possible with the current API. The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless theres emotes that hint otherwise or theres an increased use of exclamation marks and all-capital words.
Hehe, I guess I must have come off as sensitive earlier. Anyways, any hints on which class handles the capsule collision?

The reason I didn’t think capsules were working was because I normally use the BIHTree, rays and bounding volumes for collisions. For which capsules are not implemented, from what I know
[java]
/**
* The type of bounding volume being used.
/
public enum Type {
/
*
* Currently unsupported by jME3.
*/
Capsule;
}
[/java]

I guess what you have used is the CapsuleCollisionShape. I take a look at bullet and see if it has what I need.

Very cool!

I need this for jmeplanet. I just added physics support to the planets with gravity but have no way for actually walking on the surface. This solution should do nicely. When can I have it?! :wink:

This is fantastic. Glad you found it already @aaronperkins , I knew this would fit your project perfectly :smiley: Switch out the ogre with Jaime and make MonkeyGalaxy already!

I committed a first version that basically has all features implemented but still lacks damping of physics forces in the local x/z plane, the current code for that is still a bit dodgy… It still has some debug vectors enabled at all times to underline the WIP state :slight_smile: Apart from that its actually quite clean already, I added plenty of javadoc and code comments as well. Check out TestBetterCharacter to try around with whats there.

2 Likes

I added damping of the local x/z plane forces to the BetterCharacterControl and removed the debug stuffs, it should basically be complete and usable now :slight_smile:

I found that the damping works pretty intuitively. One can almost make “hovercrafts” and other things with the character too by lowering the damping value. Anyone interested could do a “space ship” with arcade physics (max speed etc) pretty easily the same way the character was done.

I’m just waiting for @aaronperkins demo update now :smiley:

LOL, I get the hint. I’ll see what i can whip up over the weekend. :wink:

Oh wow, what a treat! Thanks a lot, normen!

this is nice, is the variable gravity example in svn couldn’t find it…might help solve some body orientation needs in my game and I would like to take a look

Hideously hidden under jme3test.bullet.TestBetterCharacter :stuck_out_tongue:

@normen said: Hideously hidden under jme3test.bullet.TestBetterCharacter :P

looked round a couple times in the test “ran it” never saw the damn sphere…somehow :-? my bad sorry

This looks like a really nice addition, but I’m not certain how one is supposed to set the rotation of the collision mesh.

How is this supposed to be done?

Edit: The reason I ask is because with the default camera, the (nice!) physics debug view is showing the mesh as pointing left-right (x?) with the default rotation. I would much prefer the traditional up-down (y?) orientation.

You cannot rotate the capsule.

So, if you don’t want the capsule to be sideways with respect to the world, your best option is to ‘just’ rotate the entire world?

The capsule can never be sideways to the world as it aligns to the gravity and is circular in the local x/z plane.
You seem to be confused about the coordinate system: Y is up, X is right and Z is towards you in the default cam setup.
The content of this post is meant to be read as a straight information or question without an implicit dismissive stance or interest in having the other party feel offended unless there’s emotes that hint otherwise or there’s an increased use of exclamation marks and all-capital words.

1 Like

No, if it’s aligning itself to gravity this makes perfect sense (my gravity is not in line with the flycam or world). This is actually a better solution than having the user handle rotation manually - thanks!

Edit: Aaand I think of another case: How are we meant to handle a situation with zero gravity (my case)? I was planning to attack link the BetterCharacterControl and a cameraNode directly, but this requires being able to set the rotation of the control.