Hi,
I’m trying to create a car simulator in c#. But I have a problem:
How can I rotate the wheels during a curve with the script like this ?
public void SteerWheel()
{
FrontRightWheel.localEulerAngles.y = FrightWheel.steerAngle;
}
(FrontRightWheel is the rigidbody and FrightWheel is the WheelCollider)
Debug: Cannot modify a value type return value of `UnityEngine.Transform.localEulerAngles’. Consider storing the value in a temporary variable
I’ve already tried with :
textx= AntRightWheel.localEulerAngles.x;
texty = AntRightWheel.localEulerAngles.y;
textz = AntRightWheel.localEulerAngles.z;
FrontRightWheel.localEulerAngles is a value-type (struct). You need to assign it to a temp variable, modify the temp, then assign back to FrontRightWheel.localEulerAngles: