precise movement

hey I’ve got this code to move around my ‘player’ but the movement doesn’t feel precise … it feels slippery
any solutions to fix this in a decent way(mainly through code) ? Any help is much appreciated :slight_smile:

// right now it adds force every frame to the object’s rigidbody until the object reaches the max speed
//this is left and right movement
// _movespeed is 35f and _maxspeed is also 35f

void Update () {
if(_rigid.velocity.magnitude < _maxspeed)
{
if(Input.GetKey(“d”))
{
_input = new Vector3(1f,0f,0f);

_rigid.AddForce(_input*_movespeed);

Debug.Log(_input);
}

if(Input.GetKey(“q”))
{
_input = new Vector3(-1*1f,0f,0f);

_rigid.AddForce(_input*_movespeed);

Debug.Log(_input);
}
}

}

You might want to check out the CharacterController, controlling the player as a rigidbody is always going to feel a little “off”.

If you are using forces, you probably want to do that inside FixedUpdate, so that the physics can react correctly. Forces will most often be a bit slippery/laggy. You might be better off setting the actual velocity yourself, then you have more control over the movement.

check this script out
http://wiki.unity3d.com/index.php?title=RigidbodyFPSWalker
Specifally look at the part where the creating and clamping of the velocity is being done.