Making character to fly

I have a little problem with my character to fly. I am looking for a way to have my character to fly when I hold down a button. I have the character movement already but now, i am look for a way to have my character to fly. I looked for answers on this site relating to flying but they did not seem to work on my project. Could someone please show some sample code to make my character fly?

Well, this depends on your movement code. If it’s a custom script, edit your answer and post it - it’s impossible to help you without knowing your code. If you’re using the First Person Controller, however, you must use specific functions available in the complicated CharacterMotor.js script. A simple way to implement a kind of jet-pack feature is to add the script below to the First Person Controller:

var cMotor: CharacterMotor; // reference to the CharacterMotor script

function Start(){ // get the CharacterMotor script at Start:
	cMotor = GetComponent(CharacterMotor);

function Update(){ // move player upwards while F is pressed
	if (Input.GetKey("f")){

// This do-nothing function is included just to avoid error messages
// because SetVelocity tries to call it

function OnExternalVelocity(){