How to move a player?

i wanna move my player which is a dynamic physics node.



the surface motion has weird behaviors such as jittering. and the rotation doesnt work when the player is standing still but it rotates like crazy when the player is moving.



im trying to add a constant force to the player, but the jittering is still there, and i cant find a friction force so my player doesnt accelerate…



help~



thx

i can move the player with coordinate change per update, but i still wanna know how would i do this in physics.



and is there any advantages of moving the player with physics forces over coordinates changes?

My experiences with using physics are:

If you use a DynamicPhysicsNode, you should only move and rotate it with forces and torque.

If you mix forces and manual coordinate changes (setLocalTranslation()) it could result in jittering, but it can work in some cases.



So, to move your player, you should define correct Materials for your Player and Floor, and apply a force to your player to move it.

Keep in mind, that if you move a constant force over time, the speed will increment untill lightspeed  and even faster :wink:



You can use a FrictionCallback to reduce the applied force over time or use something like Darkfrogs  PhysicsThrustController which works nicely for me.

actually theres no jittering when im using coordinate changes, but theres terrible jittering when i use forces.



and another thing, when my player move up a hill, it sticks on the surface of the hill so hes not standing straight anymore but rather perpendicular to the surface of the hill. this looks very weird, how do i fix this?

You can make your character stand "vertical" if you bend its chest towards the top of the hill and also bend his knees a bit. Also, materials and mass need to be adequate for it not to slide down the hill.



There is no really easy solution unless you bend something to keep friction at a reasonable rate. You could use a thin "base" box on which you can attach the actual character standing on its feet. The box would follow terrain hills, and forces would make your character stand still.



The guys that made Big Fun Motorcycle Trials managed to lock an object rotation axis (so it is always in the same plane), so you might want to drop a line to MATTATTAK (I don't know if they were using JMEPhysics). There was a thread about that topic but I can't seem to find it now :(.



All this thing can get much more realistic, but way more difficult to implement. Honestly, if your character is a biped I would suggest you to not use physics for that aspect of your app (character walking).

my character is diped  :smiley:



so i guess ill just use coordinate changes then. is this the right approach?



Well coordinates are a classic :D

However don't take what I said as the absolute truth. Ask for more experienced opinions.

Also, depending on what you are doing, you might need physics for your character. But for a classic "character walking" (FPS, 3rd person view...) I think coordinates will be easier.
jjmontes said:


Well coordinates are a classic :D

However don't take what I said as the absolute truth. Ask for more experienced opinions.

Also, depending on what you are doing, you might need physics for your character. But for a classic "character walking" (FPS, 3rd person view...) I think coordinates will be easier.


thx alot. i do think coordinates r alot easier to implement and it usually gives the desired effects.

Well, since you are already discussing this here, let me ask some things.



First of all, I NEED Physics for my players, characters, etc, because they/ll have to interact with other dynamic parts of the world like boxes, houses, others players and I don

for #4, with coordinate changes, u can just use ray casting. but if u wanna use physics, u need to put a inclined surface like a slider kind thing on the stairs. so ur character will not be actually walking on the stairs but on the invisible inclined plane. this is how guild wars does it and i think it works pretty well.

Very nice indeed. I'll try it out as soon as I get back to coding game object components.

#2: you can cancel the x- and y- part of the contact normals for ground contacts of your characters in the callback