Relative Force when changing direction

i use the following code in Update() to change my character (which is a rigid body)'s direction:

gameObject.transform.Rotate(0, 90, 0);

then, I use the following code to add relative force to the character:

rigidbody.AddRelativeForce(new Vector3(speed, gameObject.transform.rotation.y, 0), ForceMode.Acceleration);

but this doesn’t work as my expectation, which is the character turns 90 degree right and start accelerating in its new direction. What did I miss?

transform.rotation is a Quaternion and its values should never be used directly.

Because you have already rotated the gameObject and are adding a relative force which is a force in the direction relative to the gameObject you can simply use Vector3.right * speed in the force function (or remove the rotation in the function):

rigidbody.AddRelativeForce(new Vector3(speed, 0, 0), ForceMode.Acceleration);

or

rigidbody.AddRelativeForce(Vector3.right * speed, ForceMode.Acceleration);