My first touch and stationary touch are responding on the same behavior

Hi all,
I have been reading and searching many days now and i am still having hard time to find solution to my problem.

I got a code (from forums) that made my character move left and right when I touch the side of the screen, and it is on the stationary phase of my touch code. My problem is on my first touch phase which is began and it should just start the game and make my rocket fly upward it also (the touchphase.began) moves the rocket from the side of my finger where it touches. I am hoping to resolve this with the help here guys. Here are the codes that i got

This is on the void update part;

if (Input.touchCount >= 1)

	{

		if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Began)
		{

			// starting touch.
			stateMachine.ProcessTriggerEvent ("TAP");

			Vector3 newVelocity = GetComponent<Rigidbody> ().velocity;
			newVelocity.y = moveSpeed;
			GetComponent<Rigidbody> ().velocity = newVelocity;
			

		}

//and this is the code i got for the stationary phase

if(Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Stationary)
{

			Vector2 touchPosition = Input.GetTouch(0).position;
			double halfScreen = Screen.width / 2.0;
			
			//Check if it is left or right?
			if(touchPosition.x < halfScreen){
				player.transform.Translate(Vector3.left * 5 * Time.deltaTime);
			} else if (touchPosition.x > halfScreen) {
				player.transform.Translate(Vector3.right * 5 * Time.deltaTime);
			}
			
		}

What should i do so that my first tap on the screen will just make the object (rocket) fly and does not move from either side.

Thanks a lot

When you first get a TouchPhase.Ended , set a boolean variable to indicate the first tap has been received. Use that boolean to prevent the unwanted stuff before that

    bool started;
	void Update ()
	{
		if (Input.touchCount >= 1)
		{
			if (!started && Input.GetTouch(0).phase == TouchPhase.Ended)
			{
				started = true;
				stateMachine.ProcessTriggerEvent ("TAP");

				Vector3 newVelocity = GetComponent<Rigidbody> ().velocity;
				newVelocity.y = moveSpeed;
				GetComponent<Rigidbody> ().velocity = newVelocity;
			} 
			else if (started && Input.GetTouch(0).phase == TouchPhase.Stationary) 
			{
				Vector2 touchPosition = Input.GetTouch(0).position;
				int halfScreen = Screen.width / 2;

				if (touchPosition.x < halfScreen) {
					player.transform.Translate (Vector3.left * 5 * Time.deltaTime);
				} else if (touchPosition.x > halfScreen) {
					player.transform.Translate (Vector3.right * 5 * Time.deltaTime);
				}
			}
		}
	}