Stoppin transform at a certain point

Hey! I just need to stop my player once it gets to a certain point:
My script:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Movement : MonoBehaviour {

	// Use this for initialization
	void Start () {

	}

	// Update is called once per frame
	void FixedUpdate () {
		var x = 2;	
		var y = Input.GetAxis ("Horizontal");
		if (Input.GetAxis ("Vertical")!= 0) {
			transform.Translate (y, 0, x + 1);
		} else {

			transform.Translate (y, 0, x);
		}
	//	if (GameObject.transform > 1000) {
		//	x = -2;
	//	} 
	}
}

Hi, I think you just need to check a condition whether it is reached to your desired point or not if it reached then avoid the translate your object.

Within the part where you move the transform you could put:

if(transform.position.x<1000f)
{
      transform.Translate (y, 0, x + 1);
}

There’s no specific way to “stop” the transform, you either use colliders or disable the movement code when moving is not required anymore.

try this. save object position when game start. then check distance from start position to current position if > = to 1000 stop it by making its velocity =0

public class Movement : MonoBehaviour {

Vector3 start_pos;

     // Use this for initialization
     void Start () {
start_pos=transform.position;

 
     }
 
     // Update is called once per frame
     void FixedUpdate () {
         var x = 2;    
         var y = Input.GetAxis ("Horizontal");
         if (Input.GetAxis ("Vertical")!= 0) {
             transform.Translate (y, 0, x + 1);
         } else {
 
             transform.Translate (y, 0, x);
         }
if( Vector3.Distance (start_pos, transform.position)>1000.0f)
{
rigidbody.velocity = Vector3.zero;
}
     //    if (GameObject.transform > 1000) {
         //    x = -2;
     //    } 
     }
 }

public class Movement : MonoBehaviour
{
float xStop = 1000f;

            void Update()
            {
                Vector3 curPos = transform.position;
                if (curPos.x >= xStop)
                {
                    curPos.x = xStop;
                    transform.position = curPos;
                    return;
                }

                var x = 2;
                var y = Input.GetAxis("Horizontal");
                if (Input.GetAxis("Vertical") != 0)
                    transform.Translate(y, 0, x + 1);
                else
                    transform.Translate(y, 0, x);
            }
        }