I try convert SmoothFollow script from JavaScript to C#:
using UnityEngine;
using System.Collections;
public class Kamera : MonoBehaviour {
public Transform obiekt;
public float distance = 10.0f;
public float height = 10.0f;
public float heightDamping = 2.0f;
public float rotationDamping = 3.0f;
void LateUpdate() {
if (!obiekt)
return;
float wantedRotationAngle = obiekt.eulerAngles.y;
float wantedHeight = obiekt.position.y + height;
float currentRotationAngle = transform.eulerAngles.y;
float currentHeight = transform.position.y;
currentRotationAngle = Mathf.LerpAngle (currentRotationAngle, wantedRotationAngle, rotationDamping * Time.deltaTime);
currentHeight = Mathf.Lerp (currentHeight, wantedHeight, heightDamping * Time.deltaTime);
Quaternion currentRotation = Quaternion.Euler (0, currentRotationAngle, 0);
transform.position = obiekt.position;
transform.position -= currentRotation * Vector3.forward * distance;
transform.position.y = currentHeight;
transform.LookAt (obiekt.transform);
}
}
I have this error:
Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable. The error concerns this line:
transform.position.y = currentHeight;
I don’t know what’s wrong