# Physics Based Player Controls

I am designing a game with a top down view, where the player can move with the WASD keys, and depending on which key presses/combinations he will move in a specific direction.

right now I am just doing this with

```               Vector3f force = new Vector3f(0,0,-1*runspeed);                 movementSphere.addForce(force);```

This force is applied to the "MovementSphere"
this changes depending on the direction but I am running into some fundamental problems.

First of all, I cannot figure out a way to limit my players force applied, and combined with friction and obstacles, it makes it difficult for me to estimate the movement of my force. Before you know it, the player is going 100 miles per hour!
What is a way I can limit my players speed so he doesnt move over that set speed?

Another problem I am running into is that, if my player changes direction, say from going north-west to going north east, the game has to gradually counter all the western based force and then once it has been eliminated to start building up eastern based force. What is a way I can have a stronger transition from moving in one direction to another?

Right now all I do is call clearDynamics(), however this leads to problems as well. If the player got blown up in the air by a grenade, and then decided to change direction, he would stop himself from moving! Another problem is that it looks jumpy to call clearDynamics and then continue to apply force afterward, because the force must build back up to full speed.

What I am thinking is I want to have the player face a certain direction, depending on which key combination, and then apply force in the "forward" direction (for example is the player was holding W and A down, he would be facing 3pi/4 direction in the x axis??) and then force would be applied to his movementSphere.
However, this will still leave me with the problem, how do I limit the velocity (i guess is the right term).
Is this the appropriate way for going about doing this?

I do like this every frame:

```         Vector3f curSpeed=new Vector3f();         pNode.getLinearVelocity(curSpeed);         if(curSpeed.length()>20){             pNode.addForce(curSpeed.mult(-10f));         } ```

If the speed of the pNode excesses a certain value, I apply an opposing force.
With the other problems, you will have to track when he touches the ground and only apply forces then.
See here: http://www.jmonkeyengine.com/forum/index.php?topic=10233.0