[Hilfe] error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.localPosition'. Consider storing the value in a temporary variable

Ich bekomme hier jedesmal die in der Überschrift genannten Fehlermeldung :frowning:
Kann mir jemand helfen und meinen Code anpassen, sodass es funktioniert?
using UnityEngine;
using System.Collections;

public class Obj_float : MonoBehaviour {


	public float maxUpAndDown = 1;            // amount of meters going up and down
	public float speed = 50;            // up and down speed

	float angle = -90;             // angle to determin the height by using the sinus
	float toDegrees = Mathf.PI/180;    // radians to degrees
	float startHeight;                // height of the object when the script starts


	void  Start (){
		startHeight = transform.localPosition.y;
	}

	void  FixedUpdate (){
		angle += speed * Time.deltaTime;
		if (angle > 270) angle -= 360;
		Debug.Log(maxUpAndDown * Mathf.Sin(angle * toDegrees));
		transform.localPosition.y = startHeight + maxUpAndDown * (1 + Mathf.Sin(angle * toDegrees)) / 2;
	}
}

You can not modify a Vector3 structure by components. You must create a new Vector3 structure and assign it to the transform.localPosition.

Vector3 newLocalPos = new Vector3(transform.localPosition.x, startHeight + maxUpAndDown * (1 + Mathf.Sin(angle * toDegrees)) / 2, transform.localPosition.z);
transform.localPosition = newLocalPos;