I am trying to convert a java script to C# from 2012 and it seem to giving nasty error i it.
Assets/Enemy1.cs(37,35): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.position’. Consider storing the value in a temporary variable
using UnityEngine;
using System.Collections;
public class Enemy1 : MonoBehaviour {
public float a;
public float b;
public float c;
public float d;
public float x3;
public float x2;
public float x1;
public int path;
public float xSpeed;
public float ySpeed;
CalcPosition calcPosition;
public int dir;
void Start () {
xSpeed = 5;
ySpeed = xSpeed;
}
// Update is called once per frame
void Update () {
calcPosition = GetComponent<CalcPosition> ();
switch (path) {
case 1:
transform.position.x += dir * xSpeed * Time.deltaTime;
transform.position.y = CalcPosition.Pos1(transform.position.x, a, x2, d);
break;
case 2:
transform.position.x += dir* xSpeed * Time.deltaTime;
transform.position.y = CalcPosition.Pos2 (transform.position.x, a, b, d);
break;
case 3:
transform.position.y -= ySpeed * Time.deltaTime;
transform.position.x = CalcPosition.Pos3(transform.position.y, a, b, d);
break;
default:
print ("Enemy1.cs: Update(): path out of range");
break;
}// switch (path)
} // Update()
}