Right way to rotate BetterCharacterControl

Hy buddies

I´m in trouble to properly rotate BetterCharacterControl. I´ve a ninja and a BetterCharacterControl added on it. I don´t want use camera direction ´cos i´ll use BetterCharacterControl in NPCs too. But i´m little confuse about how to do that.

Thanx

You use the setViewDirection() method

You´re right @BigBob … But i´m confuse about this too. The values in viewDirection are not quaternions neither angles. And when i move the ninja with setWalkDirection it move without consider rotation … :frowning:

Its a direction. To get a direction from a quaternion do something like quat.mult(Vector3f.UNIT_Z);
https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:math_for_dummies

Basically gravitiy + the view directions are enough to define all rotation for a bettercharacter controll that it is capable of.

redmonkey, if you have figured it out, could you post a code sample? Because I’m struggeling with the exact same problem atm.

betterCharacter.setViewDirection(myQuaternion.mult(Vector3f.UNIT_Z));

wow that was quick. Thanks a lot. :slight_smile:

@sumie said: wow that was quick. Thanks a lot. :)

This was said already in this thread, you could have had your answer even sooner.

Hey buddies sorry by late reply!
Everything make sense now.

Just to note like @normen said:
forward direction - quaternion.mult(Vector3f.UNIT_Z)

but sometimes you may need left direction too:
left direction - quaternion.mult(Vector3f.UNIT_X)

Thanx buddies