Helicopter scripting question

My intention is to have forward and back motion to be hover while having the space bar controlling the throttling above the hover speed, or in other words, to climb.

The problem I am having is that when I throttle up while pressing forward, then let go, the helicopter continues to accelerate upwards like the throttle is still pressed.

I am still very new to coding and I know I am doing something fundamentally wrong with with the embedded if statement or my overall logic. Any help would be greatly appreciated.

Cheers,

//HOVER
	
	if ( Input.GetAxis( "Vertical" ) != 0.0 ) 
	
	{
		rotor_Velocity += 0.005;
		tail_Rotor_Velocity = hover_Tail_Rotor_Velocity - Input.GetAxis( "Horizontal" );
		
		if ( rotor_Velocity > (hover_Rotor_Velocity * 1.15))
		
		{
			rotor_Velocity -= 0.005;
		}
		
		else
		
		{
		
		
		}
	}
	
	
	else 
	
	{
		rotor_Velocity -= 0.005;
		tail_Rotor_Velocity = hover_Tail_Rotor_Velocity - Input.GetAxis( "Horizontal" );
	}
	
	//THROTTLE
	
	if ( Input.GetKey("space"))
	 
	{
		rotor_Velocity += 0.02;
		tail_Rotor_Velocity = hover_Tail_Rotor_Velocity - Input.GetAxis( "Horizontal" );
	}
	
	else
		
	{
		
	}

I have suggested this to you before, and its something you should really consider, especially for keys already mapped. The GetAxis function is generally a better option for control to getkey in my experience. get key is great for turning stuff on and off or maybe for things like hotkeys, not so much for direct control.

What I suspect is happening is that it continues to think space is being pressed because it was the last button pressed, that combined with holding it down (safe assumption?). What happens when you press a different button after you release space?

on line 33
I would change: if (Input.GetKey(“space”))
to: if(Input.GetAxis(“Jump”)>0)

Also, you can change, add, and remove axis assignments and settings from the project input settings: Edit>Project Settings>Input (it will show up in your inspector). Increase the number at the top (the one to the right of “Size”) to add more axises…axisies…axies…whatever the plural is. lol

EDIT: Where is this code? Is this the only place that checks Input.GetKey(“space”)?

I did try what you suggested before but it had no effect. I tried it again and still no change to the overall behavior.

You must have went to bed, anyone else have any solutions?

It was the only place that checks Input.GetKey(“space”), but now its Input.GetAxis(“Throttle”)>0, with thottle defined in the input manager, as per your suggestion.