c# The left-hand side of an assignment must be a variable?

I have a swipe control script that I made. Everything is fine according to the console, everything but this error! “The left-hand side of an assignment must be a variable. a property or an indexer.” I’ve looked up solutions but none have related to my problem.

Here is my code, the error is in lines 48 and 66:

using UnityEngine;
using System.Collections;

public class SwipeMovement : MonoBehaviour
{

    Vector3 pos;                                // For movement
    float speed = 2.0f;   						// Speed of movement
    static bool[] moving;
    public float minSwipeDistY;
    public float minSwipeDistX;
    public float swipeDistVertical;
    public float swipeDistHorizontal;
    private Vector2 startPos;

    void Start()
    {
        moving = new bool[5];
        pos = transform.position;          // Take the initial position
        GetComponent<BoxCollider2D>().enabled = false;
    }

    void Update()
    {
        bool doneMoving = DoneMoving();
        if (gameObject.tag == "Player")
        {
            moving[4] = !(Vector2.Distance(transform.position, pos) < 0.01f);
        }
        else
        {
            moving[GetComponent<CollectFruit>().ID] = !(Vector2.Distance(transform.position, pos) < 0.01f);
        }

        if (Input.touchCount > 0)
        {
            Touch touch = Input.touches[0];

            switch (touch.phase) {
                case TouchPhase.Began:

                    startPos = touch.position;

                    break; 

                case TouchPhase.Ended:

                        float swipeDistVertical = (new Vector3(touch.position.y,0, 0) -= new Vector3(startPos.y,0, 0)).magnitude;

                        if (swipeDistVertical > minSwipeDistY) 
                        {
                            float swipeValue = Mathf.Sign(touch.position.y - startPos.y);
                    

                            if (swipeValue > 0 && doneMoving && transform.position.y < 1.9f) 
                            {
                                pos += Vector3.up;
                            }

                            else if (swipeValue < 0 && doneMoving && transform.position.y > -1.9f) 
                            {
                                pos += Vector3.down;
                            }
                        }

                        float swipeDistHorizontal = (new Vector3(touch.position.x,0, 0) -= new Vector3(startPos.x,0, 0)).magnitude;

                        if(swipeDistHorizontal > minSwipeDistX) 
                        {
                            float swipeValue = Mathf.Sign(touch.position.x - startPos.x);

                            if (swipeValue > 0 && doneMoving && transform.position.x > -1.9)
                            {
                                pos += Vector3.left;
                            }

                            else if (swipeValue < 0 && doneMoving && transform.position.x < 1.9) 
                            {
                                pos += Vector3.right;
                            }
                             
                       
                        }
                        break;
            }
        
      
        
     
        transform.position = Vector3.MoveTowards(transform.position, pos, Time.deltaTime * speed);    // Move there
    }
    }
    public bool DoneMoving()
    {
        return !moving[0] && !moving[1] && !moving[2] && !moving[3] && !moving[4];
    }
}

The error is occurring in this line:

new Vector3(touch.position.y,0, 0) -= new Vector3(startPos.y,0, 0)

As you probably know the -= operator is actually a shortcut for an assignment, a -= b is short for a = a-b. The error is popping up because you are assigning a new Vector3 as ‘a’ in the example and in that case you would be trying to change the value of the vector itself. To get around it you have to assign a variable to the first vector and then perform the operation on that variable:

Vector3 touch = new Vector3(touch.position.y,0, 0);
touch -= new Vector3(startPos.y,0, 0);

You have this on line 48:
float swipeDistVertical = (new Vector3(touch.position.y,0, 0) -= new Vector3(startPos.y,0, 0)).magnitude;

You’re setting a variable to the result of an assignment to a variable. Note the -= instead of just -