Should I raycast? Or is there another funtion I can use?

Hello friends I am new with Unity and wondering if there are alternatives to ray casting. My game is a road traffic manager and when the players taps a car I want it to stop. This is my code for the movement. I tried the getmousebuttondown function but realized that every gameobject with this script attached would just stop or go depending on when they spawn. Thank you in advance for your helpful advice :slight_smile:

public float SPEED;
	public Transform[] FirstPossition;
	int StopPossition;
	public bool GO = false;

	void Para()
	{
		if (Input.GetMouseButtonDown (0)) 
		{
			GO = !GO;
			if (GO)
			{
				SPEED = 5;

			} else {
				SPEED = 0;

			}
			//GO = false;
		}

	}


	void Start () {
		StopPossition = 0;
	}


	void Update()
	{

		if (transform.position == FirstPossition [StopPossition].transform.position) 
		{
			StopPossition+=Random.Range(0,4);
		}

		transform.position = Vector3.MoveTowards (transform.position, FirstPossition [StopPossition].position, SPEED * Time.deltaTime);

		if (StopPossition >= 5) 
		{
			StopPossition = 0;
		}

		Para ();

		Debug.Log (StopPossition);

	}

You could do raycasting yourself which gives you a lot more flexibility and control should you need it later on. However if your objects have colliders on them you can also use a built-in method of monobehaviours that responds to clicking on those colliders (sort of a built-in raycast for you).