Problem with moving in FixedUpdate

It’s my code
Vector2 MOVE;
public float timer=5;

void FixedUpdate(){

		GetComponent<Rigidbody2D> ().velocity = MOVE;

	else if(timer<0){
	GetComponent<Rigidbody2D> ().velocity =;

public void MoveToLeftAndRight(){

	if ((Input.GetAxisRaw ("Horizontal") > 0 || Input.GetAxisRaw ("Horizontal") < 0) ) {

		MOVE= new Vector2 (MoveSpeed * Input.GetAxisRaw ("Horizontal"), GetComponent<Rigidbody2D> ().velocity.y);
		transform.localScale = new Vector3 (1 * (Input.GetAxisRaw ("Horizontal")), 1, 1);

	else if(Input.GetAxisRaw ("Horizontal") == 0){
		MOVE = new Vector2 (0, GetComponent<Rigidbody2D> ().velocity.y);
void Update () {

		 MoveToLeftAndRight ();


if I press D after 5 sec my x position is always 30,
but if I click on D several times after 5 sec the position won’t be 30,it’s something between 20 and 28.

what should I do now?I want the position to be always one thing .

The difference comes from the fact that Update () and FixedUpdate () are asynchronous. It could be FixedUpdate () => FixedUpdate () => Update () or any situation that causes you to miss out on a small amount of deltaTime. So you should use only Update (), or FixedUpdate ().

P / s: If you are trying to move a gameobject exactly, do not use Rigibody, but instead try using Transform.

If I push D my character after 5 secs is at position 30,
but if I push D then don’t push it then push it again and do it for several times
my character won’t get to position 30, The timer that I made works when you push key
so when you don’t push it ,timer wont work,I want my character to get to position 30 If I push my finger On D key for 5 sec or push it and don’t push it until timer goes 0.
hope you get what I want :slight_smile:
sorry for very Bad English.