How can you make a FPS controller camera "fly"?

Hi there,

I'm trying to figure out how I can make my FPS controller go up or down (based on my mouse Y coordinates).

I'm using 0 gravity and it lets me roam around across the x and z axis, I just have no control over the Y axis.

EDIT: The part which determines the Y velocity when the camera isn't touching the ground looks like this:

private function ApplyGravityAndJumping (velocity : Vector3) {

    if (!inputJump || !canControl) {
        jumping.holdingJumpButton = false;
        jumping.lastButtonDownTime = -100;
    }

    if (inputJump && jumping.lastButtonDownTime < 0 && canControl)
        jumping.lastButtonDownTime = Time.time;

    if (grounded)
        velocity.y = Mathf.Min(0, velocity.y) - movement.gravity * Time.deltaTime;
    else {
        velocity.y = movement.velocity.y - movement.gravity * Time.deltaTime;

        // When jumping up we don't apply gravity for some time when the user is holding the jump button.
        // This gives more control over jump height by pressing the button longer.
        if (jumping.jumping && jumping.holdingJumpButton) {
            // Calculate the duration that the extra jump force should have effect.
            // If we're still less than that duration after the jumping time, apply the force.
            if (Time.time < jumping.lastStartTime + jumping.extraHeight / CalculateJumpVerticalSpeed(jumping.baseHeight)) {
                // Negate the gravity we just applied, except we push in jumpDir rather than jump upwards.
                velocity += jumping.jumpDir * movement.gravity * Time.deltaTime;
            }
        }

        // Make sure we don't fall any faster than maxFallSpeed. This gives our character a terminal velocity.
        velocity.y = Mathf.Max (velocity.y, -movement.maxFallSpeed);
    }

    if (grounded) {
        // Jump only if the jump button was pressed down in the last 0.2 seconds.
        // We use this check instead of checking if it's pressed down right now
        // because players will often try to jump in the exact moment when hitting the ground after a jump
        // and if they hit the button a fraction of a second too soon and no new jump happens as a consequence,
        // it's confusing and it feels like the game is buggy.
        if (jumping.enabled && canControl && (Time.time - jumping.lastButtonDownTime < 0.2)) {
            grounded = false;
            jumping.jumping = true;
            jumping.lastStartTime = Time.time;
            jumping.lastButtonDownTime = -100;
            jumping.holdingJumpButton = true;

            // Calculate the jumping direction
            if (TooSteep())
                jumping.jumpDir = Vector3.Slerp(Vector3.up, groundNormal, jumping.steepPerpAmount);
            else
                jumping.jumpDir = Vector3.Slerp(Vector3.up, groundNormal, jumping.perpAmount);

            // Apply the jumping force to the velocity. Cancel any vertical velocity first.
            velocity.y = 0;
            velocity += jumping.jumpDir * CalculateJumpVerticalSpeed (jumping.baseHeight);

            // Apply inertia from platform
            if (movingPlatform.enabled &&
                (movingPlatform.movementTransfer == MovementTransferOnJump.InitTransfer ||
                movingPlatform.movementTransfer == MovementTransferOnJump.PermaTransfer)
            ) {
                movement.frameVelocity = movingPlatform.platformVelocity;
                velocity += movingPlatform.platformVelocity;
            }

            SendMessage("OnJump", SendMessageOptions.DontRequireReceiver);
        }
        else {
            jumping.holdingJumpButton = false;
        }
    }

    return velocity;
}

That part deals with gravity and jumping. There are a couple of other code snipets which also deal with it... The script is almost 600 lines long and tonight is the first time I've even look at scripts sorry. :S Oh and also - I've disabled jumping, but am not sure if the code entails that because I'm not grounded initially, that I'm in a jump state. 3am so forgive me for not looking right now. :[

I've heard there is a fly through camera somewhere, but I've been looking for almost 4 hours now and I've had no luck. This is agonising. Any help would be duly appreciated please

post the code which you are using to control at the moment. Have you added an axis and referenced that axis in code to control the y position of your object? I realise this isn't an answer but if I post a comment you will not be able to update me. I will edit my answer to be of use for you when I get more information :)

EDIT

Basically inordeer to get the character to move in 3 dimensions you need to find the section in the script which determines your character controllers move direction. Somewhere in the script will be a line which states how much movement to apply to the y axis every frame in order to simulate gravity. You can reduce that number to 0 and it will stop it from falling by default. Then you have to map an input axis in the input settings name it something like "Height" using this input axis in the script, assuming the section that moves reads movement via some form of

`moveDirection = Vector3(Input.GetAxis("Horizontal"),0,Input.GetAxis("Vertical"));`

add your input axis to the vector3 y axis there

moveDirection = Vector3(Input.GetAxis("Horizontal"),Input.GetAxis("Height"),Input.GetAxis("Vertical"));

If you have turned gravity to 0 in the physics manager this only effects rigidbodies and does not determine the gravity of a character controller component.

EDIT 2

right now that I realise what the code looks like what you need to do is take out all of that code, if you dont want any gravity and you dont need a jump then what you need to do is find the section in the scripts which calls/activates that function and delete it or comment it out. It occurs to me now that you would be better off using a rigidbody and adding force to it based on your inputs.

Unity is a heavily script based game engine and if you want it to really customise a game or make an individual one then you will have to learn to programme. Stealing scripts and using default scripts will only get you so far and it will never make your game unique.