localEulerAngles

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;

but i can’t understand it !!! :face_with_spiral_eyes:

Annoying but you have to do the entire vector at once due to the way the Vector3 struct is implemented:

FrontRightWheel.localEulerAngles = new Vector3( 
FrontRightWheel.localEulerAngles.x, 
AntRightWheel.localEulerAngles.y,
 FrontRightWheel.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:

Vector3 angles = FrontRightWheel.localEulerAngles;
angles.y = FrightWheel.steerAngle;
FrontRightWheel.localEulerAngles = angles;

wooooooooooorks :slight_smile: … thank you very much guys :slight_smile: