# Unity 2D: Why does my character stutter if I add deltaTime to moveSpeed?

So I'm following a tutorial on youtube, first time Unity user, but been making games in other frameweorks before. In the tutorial he does not use deltaTime for movement, which has always been the standard for me, so I added it my self, but it makes my character "stutter/lag" really weirdly (does not stutter without deltaTime). Surely I must use deltaTime for movement in the Update()method?

Script for Player movement:

void Update () {

playerMoving = false;

if (!playerAttacking) {
Vector2 direction = new Vector2();

if (Mathf.Abs (Input.GetAxisRaw ("Horizontal")) > 0.5f) {
Debug.Log ("Moving on X");
playerMoving = true;
direction.x = Input.GetAxisRaw ("Horizontal");
lastMove.x = direction.x;
lastMove.y = 0;
}

if (Mathf.Abs (Input.GetAxisRaw ("Vertical")) > 0.5f) {
Debug.Log ("Moving on Y");
playerMoving = true;
direction.y = Input.GetAxisRaw ("Vertical");
lastMove.y = direction.y;
lastMove.x = 0;
}

if (playerMoving) {
myRigidBody.velocity = direction.normalized * moveSpeed * Time.deltaTime;
} else {
myRigidBody.velocity = Vector2.zero;
}
}


My Camera (Stutters unless I use fixedUpdate):

void FixedUpdate () {
targetPos = new Vector3 (followTarget.transform.position.x, followTarget.transform.position.y, transform.position.z);
transform.position = Vector3.Lerp (transform.position, targetPos, moveSpeed);
}


The problem is that you're setting velocity. Since it goes without saying that distance = time x velocity, what you're doing now is distance = time x (velocity x time). If you were setting the position of your object, then multiplying by delta time would have made sense.
In short, you shouldn't be multiplying velocity by time. Again, if it was something like acceleration that you were using, since velocity = time x acceleration, the formula would've changed as follows:
myRigidBody.velocity = myRigidBody.velocity + (direction.normalized * acceleration * Time.deltaTime);

• One more question, should I be controlling movement inside Update or FixedUpdate? Simply setting myRigidBody.position += direction.normalized * moveSpeed * Time.deltaTime Didn't work. I see some people using addForce inside FixedUpdate, for movement – Green_qaue May 28 '17 at 9:22