Register Ceiling hits while jumping

So I am new to C# and just messing with a 2D platformer. I have a script that controls the character, but when I jump and hit a ceiling it floats for a bit. I want to be able to test its position against itself and say if it is no long moving up, to reapply gravity. I can find out the objects current position, but I don’t know how to compare it to it’s last frame to see if it is moving or not. Wondering if there is a NoChange kinda thing somewhere… I also dont want to make is collision based so it doesn’t get forced down when hitting a wall.


You can check for collisions specifically above you, heres how:

//I'm just guessing what variables you have, since you gave no such information
var Velocity:Vector3;

function Update() {
    //If we hit something above us AND we are moving up, reverse vertical movement
    if ((controller.collisionFlags & CollisionFlags.Above) != 0) {
        if (velocity.y > 0) {
            velocity.y = -velocity.y

Hope this helps,