JME : CharacterControl does not rotate, multiple ways tried


For a prototype game where we are evaluating JME, I am trying to rotate the player which is of type CharacterControl, and it’s not working. These are the links I have read to understand how you can turn CharacterControl 1, 2, 3, 4, 5.

Link-1 contains old API’s I presume because .getLocalRotation() is not available anymore.

The 5th link which is a nice presentation about vectors, although quite good for rotating/turning/flipping other objects, only theory regarding CharacterControl is presented, no examples. Still, going through the links, I found out that I can set the viewDirection of the player, but no combination or vector attributes helped. So, what am I missing?

Code :

    CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.5f, 6f, 1);
    player = new CharacterControl(capsuleShape, 0.05f);
    player.setPhysicsLocation(new Vector3f(0, 10, -50));
    shootables = new Node("Shootables");

Thank you for your help.

a) Use BetterCharacterControl

Quaternion q = new Quaternion();
float angleInDegrees = 30;
q.fromAngleAxis(Vector3f.UNIT_Y, FastMath.2PI / 360 * angleInDegrees);
Vector3f view = q.mult(Vector3f.UNIT_Z); // or
view = Vector3f.UNIT_Z.mult(q); // Can't remember which

View is simply the ViewDirection.
You’d use betterCharacterControl.setViewDirection(view);

But I am not looking for BetterCharacterControl, just for rotating, I don’t want to change the code throughout the file only to rotate by 180 degree. Some of which is not even supported with how its already programmed.

As far as I know the old CharacterControl is deprecated…
If not already done someone should fix the beginner tutorials on the wiki.

Does that mean I can’t even rotate a CharacterControl object?

Actually you should just use BetterCharachterControl since it’s BETTER.
Anyway you can also use setViewDirection(view) for the usual CharacterControl.

A fast google would come up with this
Also you could’ve tried to look for something comparable to setViewDirection or google how to set it.
Anyway, you will call: player.setViewDirection(view); .

You won’t get far without learning how to help yourself/search correctly

and don’t be afraid if the betterCharaterControl don’t fit your needs you can still extends it and make it fit .

BetterCharacterControl is not better in everyaspect. I got bugs with it, bugs that cannot be solve easily and involved a lot a complex code to solve in charactercontrol. You know, this code that was removed in the bettercharactercontrol because it was too hard to evolve it.
BetterCharacterControl is a controller based on a physic object, i.e. with momentum etc. For this aspect it’s great. However it fails for every other aspect, and the feature it adds (like the possibility to change the gravity) doesn’t work for the most obvious case: 90/180 degrees change.

CharacterControl was deprecated in a second without a debate, without a vote, without investigating on whether the bettercharactercontrol was actually better or not.
The fact is that these two way of controlling a character are two alternative ways. None of them is good, even for a plain fps game (and for a fps charactercontrol is actually a bit better).

1 Like