Correcting Gravity in C#

I am trying to get gravity working with a custom character controller based script, one that allows my player to dive underwater and resurface when the space bar is released. However… at the moment, the ability to resurface is playing havoc with the gravity itself. The two seem to be conflicting somehow, but I’m not entirely sure why. I’m using the character controller instead of physics as it has so far provided the best results, up until now.

When the character is at water level, which is the normal position, it’s jittering hard on the y axis.

The main goal is to get the character to go back to the water plane when they dive down from land.

http://pastebin.com/rcv29Vjz

I would use Rigidbody.useGravity. That way Unity’s built in gravity will work, except when you want to do things like jump and surface. Basically any time a key is pressed/held that would do an action against gravity, you can call this to toggle gravity off/etc. It’s a bit more reliable than using your own gravity because it takes advantage of all the Rigidbody characteristics.

Can a Rigidbody and Character Controller get along well?