Moving Platform Coding Question

I’m trying to make a simple moving platform script using c#. The following code is based on someone else’s code that was done in javascript. i tried to replicate it in c# but I get the cs1612 error. any help is appreciated.

private float platform_x;
	private float platform_y;

	private bool max;

	public bool vert;
	public int maxAmount;
	public float step;


	// Use this for initialization
	void Start () {

		platform_x = transform.position.x; //setting up the initial value
		platform_y = transform.position.y;

	}
	
	// Update is called once per frame
	void Update () 
	{
		//SET THE MAX
		if (vert) {
			if (transform.position.y >= platform_y + maxAmount) {
				max = true;
			} else if (transform.position.y <= platform_y) {
				max = false;
			}
		} else{//Horizontal
			if (transform.position.x >= platform_x + maxAmount) {
				max = true;
			} else if (transform.position.x <= platform_x) {
				max = false;
			}

		// MOVING THE PLATFORM
				if (vert) {

						if (!max) {
								transform.position.y += step;
						} else {
								transform.position.y -= step;
						}
				} else {
						if (!max) {
								transform.position.x += step;
						} else {
								transform.position.x -= step;
						}
				}

		}

This is because in C#, the individual coordinates of a vector aren’t settable when accessed through a property the way transform.position is. Thus, you can’t set the x and y coordinates of your transform.position directly like that. You have to re-instantiate the whole vector and assign it back.

Change lines like this:

  transform.position.y += step;

To:

transform.position = new Vector3(transform.position.x, transform.position.y + step, transform.position.z);

Or, alternatively (to add step to y):

transform.position += new Vector3(0, step, 0);