I have attempted to convert a JS code into C# but in Unity error message error CS1612: Can not modify a value type return value of `UnityEngine.Transform.localEulerAngles'. Consider storing the value in a temporary variable guide me to solve my problem
void Update () {
WFL.localEulerAngles.y = W_FL.steerAngle - WFL.localEulerAngles.z;
WFR.localEulerAngles.y= W_FR.steerAngle - WFR.localEulerAngles.z;
}
Answer by Commoble · Mar 04, 2017 at 11:29 PM
You can't modify individual x/y/z components of vectors in Transforms. You have to set the whole vector at once, e.g. like this:
Vector3 oldWFLAngles = WFL.localEulerAngles;
WFL.localEulerAngles = new Vector3(
oldWFLAngles.x,
W_FL.steerAngle - oldWFLAngles.z,
oldWFLAngles.z);
EDIT: spread vector across multiple lines to make it more readable
Your answer
Follow this Question
Related Questions
can someone pls help me. c# to js 1 Answer
convertir un pequeño codigo de js a c# / convert a little code of js to c# 0 Answers
cannot be an iterator block because `void' is not an iterator interface type 1 Answer
I want to create a game type Crash Bandicoot (I need help) 3 Answers
hi. I am a junior in unity. But i now JS very good. I am a web Developer. 3 Answers