Simple math problem

I’ve been using JME for 2 days, and am following the tutorials and Math for Dummies guide, but still cannot get something right.

I am using physics, and have a CharacterControl. I want to rotate it left and right on the spot, with no additional movement (and no camera movement, I’m using the FlyByCamera - so like the HelloCollision tutorial, but without a first person camera to get rotation from).

This is the code for me trying to rotate it 45 degrees around the Y axis

Quaternion roll45 = new Quaternion();
roll45.fromAngleAxis(-FastMath.QUARTER_PI, Vector3f.UNIT_Y);

vectorB = roll45.mult(characterControl.getViewDirection());

System.out.println("final view direction: "+vectorB.toString());


I’ve tried playing with it but the result I get in vectorB is always 0,0,0.

Also I have noticed that despite doing CharacterControl.setViewDirection(1,0,0); or any other set of numbers, as soon as I do getViewDirection() in my update loop it is set back to 0,0,0. Not sure how I use this?

Your math looks OK, so I think the view direction must be getting zeroed somewhere else. Once it’s zero, rotation has no effect.

1 Like

Ok thanks, I must be zeroing it somewere, will search for this now.

edit: Yeah I had been doing that. Thanks