If statement doesn't work

Dear community,

I have a quad that acts as a scrolling background, and moves from right to left. I wish for it to stop once it has reached a certain Vector3 position, but my If statement does not seem to work (the Debug.Log does not return anything). Is there any mistake with my code?

	private Vector3 startPosition;
	private Vector3 endPosition;
	public float scrollSpeed;

	void Start () 
	{
		startPosition = transform.position;
		endPosition = new Vector3 (10.0f, 0.5f, 10f);
		scrollSpeed = 1f;
	}

	void Update () 
	{
		transform.position = startPosition + Vector3.left * scrollSpeed * Time.timeSinceLevelLoad;
		if (transform.position == endPosition) {
			Debug.Log (transform.position);
			scrollSpeed = scrollSpeed - 1f;
		}
	}

Any help is greatly appreciated =)

The if condition is trying to match two vectors exactly and based on how transform.position is being updated it will likely exceed endPosition without ever being exactly equal. Furthermore, even if they did match, the Update() function is called every frame and the next cycle will update the transform position again.

If all you are looking to perform is have the background object simply move to the left and stop, try the following. This assumes the left motion is the x-axis. but can be adjusted to any vector considered as the left direction.

using UnityEngine;
using System.Collections;

public class LeftRight : MonoBehaviour {

    private Vector3 startPosition;
    private Vector3 endPosition;
    public float scrollSpeed;

    void Start()
    {
        endPosition = transform.position; 
        endPosition.x = transform.position.x - 10f;
        scrollSpeed = 1f;
    }

    void Update()
    {
        if (InMotion())
        {
            if (Mathf.Abs(transform.position.x) <= Mathf.Abs(endPosition.x))
            {
                transform.position = transform.position + Vector3.left * scrollSpeed * Time.deltaTime;
            }
            else
            {
                Debug.Log(transform.position);
                scrollSpeed = 0f;
            }
        }
    }

    bool InMotion()
    {
        return scrollSpeed > 0f;
    }
}