Input when not in contact with floor

Im making a skateboarding game at the moment for a college project, i have a couple of inputs to control and flip my board, but i dont want to be able to use the input to flip my board while in contact with the floor but i cant figure out the script to do this, i have the script to flip the board but i only want to be able to use it once my skateboard is in the air. would be much appreciated if anyone could help.

How to properly answer this will depend on how you set up everything else. If you're using a character collider for movement, the FPSWalker script has an example of how to determine if you're on the ground (off the top of my head, it's something like checking to a bit flag off the return value of .Move()). If you're using wheel colliders on your board, you can use the isGrounded property to just ask if it's on the ground or not.

One thing you could do regardless of anything else, is every frame do a Physics.Raycast to determine if you're on the ground or not. Trace from the player or board or whatever downward, and see if you hit the floor. If you make your ray length pretty small (say, the height of a skateboard wheel), then the question simply becomes "did raycast hit anything".

I'm assuming you can figure out how to turn off your in-air trick input once you can answer the question "am I on the ground".

If you are using a character controller you can structure your controller.Move call to be like this:

CollisionFlags flags = controller.Move(velocity * Time.deltaTime);
if ((flags & CollisionFlags.Below) != 0)
    grounded = true;
    grounded = false;

grounded will be true when the character is in contact with the ground.

Alternatively, there is also a characterController.isGrounded property, however some of Unity's resources show that the characterController's built in properties can be unreliable at times (namely the scripts in the Character Animation Example Project).

You will need to determine whether or not your skateboard is touching the ground.

private groundHitCount : int = 0;

function OnCollisionEnter (collision : Collision) {
    // Determine if it's a ground hit (using tags or vertical raycasting)

function OnCollisionExit (collision : Collision) {
    // Determine if it's a ground hit (using tags or vertical raycasting)

function AmIGrounded () {
    return (groundHitCount > 0);

function Update () {
    if (AmIGrounded()) {
        // Ground input here
    } else {
        // Air input here

Making this up as I go but hopefully it at least gets you started.