Problem with rigidbody rotation

hello friends, first of all I must tell you that I’m new to unity I am, I’m doing a script in C# that controls the movement of an Osprey i’m using a model with rigidbody I think is a more realistic alternative. I show a little code:

for elevation:
rigidbody.velocity = new Vector3(0, elevation, 0);

for rotation:
rigidbody.MoveRotation(Quaternion.Euler(ospreyEuler));

Now the problem arises here when I want to apply a force forward or backward:
rigidbody.AddRelativeForce(transform.forward * verticalSpeed, ForceMode.Impulse);

once rotated model the forward vector object is not updated so that upon application of the force moves in what was forward before rotation ie if there is a rotation in the osprey 90 degrees to the right and apply the force for forward the osprey is moving to the left and vice versa.

You either want:

rigidbody.AddRelativeForce(Vector3.forward * verticalSpeed, ForceMode.Impulse);

or:

rigidbody.AddForce(transform.forward * verticalSpeed, ForceMode.Impulse);

‘transform.forward’ is a world coordinate, not a local coordinate.

the error was in freeze position settings, had blocked the freeze position x the code was like this:

// turning
horizontalMovement = Input.GetAxis("Horizontal");
ospreyPitch = Mathf.Lerp(ospreyPitch, -30 * horizontalMovement, Time.deltaTime);
Vector3 ospreyEuler = rigidbody.rotation.eulerAngles;
ospreyEuler.z = ospreyPitch;
		
if (horizontalMovement > 0)
{
	rotationSpeed = Mathf.Lerp(rotationSpeed, maxRotationSpeed, Time.deltaTime);
	ospreyEuler.y += Time.deltaTime * rotationSpeed;
}
else if (horizontalMovement < 0)
{
	rotationSpeed = Mathf.Lerp(rotationSpeed, maxRotationSpeed, Time.deltaTime);
	ospreyEuler.y -= Time.deltaTime * rotationSpeed;
}
else
{
	rotationSpeed = Mathf.Lerp(rotationSpeed, 0, Time.deltaTime *10f);
}
		
rigidbody.rotation = Quaternion.Euler(ospreyEuler);
Vector3 targetVelocity = new Vector3(0, elevation, verticalSpeed);
targetVelocity = transform.TransformDirection(targetVelocity);
Vector3 velocity = rigidbody.velocity;
Vector3 velocityChange = (targetVelocity - velocity);
		
rigidbody.AddForce(velocityChange, ForceMode.Impulse);

thanks!