BetterCharacterControl in the works

@Fiarr said: 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.

Check out the javadoc of the character, it tells you how the character works. In the case of zero gravity I wouldn’t use the character, simple as that ^^ Just make a RigidBody that counters the forces applied on it like the character does or set it to kinematic right away.

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.

I’ll give that a shot, thanks!

@Fiarr said: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.
Btw, TestBetterCharacter has an example of a third-person cam using a CameraNode when you press enter. 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.

I seem to have a small problem when stepping onto slightly elevated platforms such as street to sidewalk in town.j3o for example.
Though in the levels i have their are no elevated platform really it could be an issue at a later time.
The character jumps up off the ground when going from one elevation to the next even if it is small and at faster speeds is flung into the air.
I have this problem with a custom control but posted it here when i tried BetterCharacterControl to see if it has the same problem, i don’t think it happens with CharacterControl though. I used the example for bettercharactercontrol and substituted the box geometry for town.j3o.

Another problem is that in my control if i run into an obstacle while off the ground it will stick and i will be forced to restart the application as collision isn’t registered however in bettercharactercontrol the character can cling to the wall if the directional vector is not zeroed though i’m not sure if this is intended or ignored.

Its ignored. I don’t understand your first problem though?

Great work normen! I really appreciate your work on a better CharacterControl! I will switch to it as soon as it is out of experimental state.

But what I don’t understand: so the new BetterCharacterControl is still in an experimental state but the old CharacterControl is already marked deprecated?

In nightly yeah. Theres more irrationalities in that :wink:

@normen
if you load town.j30 from the repo instead of a simple plane and go through the town and from off of the streets onto the sidewalk the character kind of jumps up. This is a bit easier to see if the speed is increased then the character flys through the air

@Bonechilla said: @normen if you load town.j30 from the repo instead of a simple plane and go through the town and from off of the streets onto the sidewalk the character kind of jumps up. This is a bit easier to see if the speed is increased then the character flys through the air

Well I guess its the character bouncing off the edge. You basically do this:

To counteract this I could add countering of upwards forces while the character is on the ground and not jumping but that would make it kind of “stick” to the floor…

1 Like

Thanks normen, this is really nice!

Hi,

@normen greate work with this control, i made some tests with TestBetterCharacter.java and i have one question. It is a requirement that the center of the model must set his center to foot like Jaime? I replace Jaime for Sinbad and it sank to the ground until his center.

add the model to a node, then add the BetterCharacterControl to the node, and move the model until it is in the correct place for you

1 Like

Hi,

I will try this, tank you.

I noted some changes, switching from CharacterControl -> BetterCharacterControl (using trunk from 6 days ago)

  • One is that its not affected by gravitation if there is no gravitation the physics space? Earlier i had PhysicSpace.setGravity(Vector3f.ZERO.clone()), Really i needed this to give my “projectiles” have mass made but avoid gravity. Now this doesnt work anymore => leads to my BCC’s having no gravity. PS. Noted that i need to set the “up” direction using gravity on physicsspace also. Can be accomplished setting a super short vector in some direction. DS.

  • With CharacterControl setWalkDirection seemed to indicate “Translate- To” in “tpf” (time per frame), now its more of a velocity. I wonder if theres a way to control “Translate-To” in some deterministic way with BetterCharacterControl. What do i need to set X to travel distance Y for given “time” and “steps” below:

[java]myBetterCharacterControl.setWalkDirection(X);
myPhysicsSpace.update(time, steps);
myPhysicsSpace.distributeEvents();[/java]

(ie, i have a usecase where my phyiscs space is detached from BulletAppState and thus i step time myself)

  1. Yeah, the character is now properly affected by gravity as it should be.
  2. The walkDirection is now a velocity in m/s instead of dependent on the internal physics framerate which made no sense (as the bullet developer agrees).
1 Like
@normen said: 1) Yeah, the character is now properly affected by gravity as it should be. 2) The walkDirection is now a velocity in m/s instead of dependent on the internal physics framerate which made no sense (as the bullet developer agrees).

Oh ok. Regarding 2, so what clock does physics space (when disconnected from bullet) rely on - ie can u control the flow of time yourself ? How would one set WalkDirection to walk X meters?

Its meters per second, m/s… https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:physics

Need to look into whats causing my model to fail. Getting different results on client and server. I guess im doing something wrong.

Hi all,

i’ve been using BetterCharacterControl for a few days, and this class seems very usefull :slight_smile: I would however make a small suggestion (if i’m right) or would need advice (if i’m wrong).

The checkOnGround() method does not take the collision groups that are ignored into account (i.e. the BetterCharacterControl considers that it is grounded even if it does not collide with the other control, and is then able to jump on it). I wanted to have this feature (if i’m right, maybe it would be a good default feature ?) and overrode checkOnGround in my subclass. But since i find bitmasks a -bit- confusing, would it be possible to tell me if the following implementation is correct:

in the BetterCharacterControl subclass initialization:
[java]
this.rigidBody.setCollisionGroup(RigidBodyControl.COLLISION_GROUP_02);
this.rigidBody.removeCollideWithGroup(RigidBodyControl.COLLISION_GROUP_02);
[/java]

And in the other custom controller initialization:
[java]
this.setCollisionGroup(RigidBodyControl.COLLISION_GROUP_02);
[/java]

Finally, here is the implementation of checkOnGround():
[java]
protected void checkOnGround(){
TempVars vars = TempVars.get();
Vector3f location = vars.vect1;
Vector3f rayVector = vars.vect2;
float height = getFinalHeight();
location.set(localUp).multLocal(height).addLocal(this.location);
rayVector.set(localUp).multLocal(-height - FastMath.ZERO_TOLERANCE).addLocal(location);
debugTools.setMagentaArrow(location, rayVector.subtract(location));
List<PhysicsRayTestResult> results = space.rayTest(location, rayVector);
vars.release();
for (PhysicsRayTestResult physicsRayTestResult : results) {
if (!physicsRayTestResult.getCollisionObject().equals(rigidBody)) {
// The only difference with original implementation is here:
if((this.rigidBody.getCollideWithGroups() & physicsRayTestResult.getCollisionObject().getCollisionGroup()) != 0){
onGround = true;
return;
}
}
}
onGround = false;
}
[/java]

This works fine in my project, but i’m not sure it would be correct in general…

Thanks!

How does one draw the betterCharacterControl collision shape?I tried to use getShape() however it return a CollisionShape which does not give me any Spatial to draw in the scene…
Any help would be apreciated