hey,
I have 2 questions 1 is not really related to physics but is related to to my other1.
Ill explain what i am trying to do first.
i want the player character in thirdpersonview to always walk "forward" in the camera direction by pressing W
S is backwards offcourse and A and D will make him strafe left and right. this is all done in respect to the camera direction. To make the character not look very weird by moving in 1 direction while walking in the other i also point him in the camera direction via lookAt().
I was moving my character with forces but he had problems walking on anything but flat terrain so i was gonna try to see if surfacemotion would be a better way to move him.
in my first setup the character was walking forward in whatever direction i had the camera pointing by adding forces in the camera direction
tempVec = cam.getDirection().normalize();
tempVec.y = 0f;
((DynamicPhysicsNode) target).addForce(tempVec.mult(time * force));
I set the Y to 0 because otherwise he would be trying to walk down/up a bit because of the camera angle
(This is also causing my second problem i think).
However by changing the addforce to surfacemotion the direction is completely wrong
((DynamicPhysicsNode) target).getMaterial().setSurfaceMotion(
tempVec.mult(time * force));
How do i fix my directions ?
on to the second problem .. slopes.
Whenever he comes on a steep slope he wobbles down instead of slides i suspect this has to do something with the fact that i make him lookAt the camera direction with the y=0. if i dont set y to 0 he keeps falling over because the camera is above and behind the player looking a bit down on him.
target.getLocalRotation().lookAt(tempVec.negate(), Vector3f.UNIT_Y);
this is still the same tempVec as above.
So how can i get rid of the wobbeling ? simply changing the material to slide more wont work because then it just looks like he is walking on ice or something
I could live with a wobbly guy on slopes but i really do need correct directions for him.
Any help is appreciated
Hellmaster