Get a value that interpolates between two floats based on where character is facing

I’m making a controller script for a paper airplane and I’m currently stuck on trying to make the plane gain speed when facing down but lose speed when facing up.

The ideal way would be having a value that’s 0 when facing right or left but drops to -1 when facing up and 1 when facing down (It doesn’t really matter which is 1 or -1 just that they’re distinguishable).
Then I’d just multiply that value (which is somewhere in between -1 and 1) by gain and add that to my speed variable like this speed += value * gain.

Here’s a picture to better understand.

I already got the information where the plane is currently facing (both in vector form and degrees) but how can I do this?


Below line would give you a value between 1 and 0. 1 when the transform looks downward with 90 degrees and 0 when directly upwards.

var dir =  -transform.forward.y * 0.5f + 0.5f   

If you don’t want to stop the plane completely when it looks upwards, instead of multiplying your movement speed value directly with this value, I would suggest using a lerp.

var dir =  -transform.forward.y * 0.5f + 0.5f;
speed = Mathf.Lerp( minSpeed, maxSpeed, dir);