Normally this is error is not a problem for me, but I can’t get it right this time. I’m trying to write to transform.rotation by storing the variables in a temporary variable then assigning the temp variable to the transform.rotation. Here is the error and the code. Please take a look and slap my hands if it was simple.
Assets/Scripts/Weapon.cs(24,35): error CS1612: Cannot modify a value type return value of `UnityEngine.Transform.rotation’. Consider storing the value in a temporary variable
Vector3 currentAngles = transform.rotation.eulerAngles;
currentAngles.y = Mathf.LerpAngle(currentAngles.y,targetAngles.y,Time.deltaTime);
transform.rotation.eulerAngles = currentAngles;