HoverBoard Script (Please help! Or as we also know, plz hlp!!)

Hey guys, Ethaninja here, on my hands and knees again, begging for mercy and clarification!

So, basically, I’m creating a hoverboard game right, and well of course my hoverboard needs to hover. Now just for a bit of elaboration; I want the board to hover ever so slightly up and down when not moving. If you catch my drift :stuck_out_tongue: Hopefully you get what I am trying to achieve by me telling you or showing you my code :stuck_out_tongue: The problem is, it just moves up once, and doesn’t come back down again. Also, it does it instantly, not smoothly.

Now, this is sort of what I was going for:

/*
Name: hoverScript.cs
Author: Ethan Roberts

Description:
This script is for use in conjuncture with all hoverboards.
It's purpose is for a simple "idle hover" behaviour
*/

using UnityEngine;
using System.Collections;

public class hoverScript : MonoBehaviour {
	
bool bHover = true;	
float fOrigin = 0.0f;	
float fPosHeight = 2.0f;
	

	void Start () {
			
		if (fOrigin == fOrigin){
			transform.Translate (0, fPosHeight,0);
		}
	
		if(fOrigin >= fPosHeight){
			transform.Translate (0, fOrigin,0);
			}
		
	}
	

	void Update () {
	
		
	}
}

Before you start shouting at me and spanking me, I must remind you all that I AM a giant n00bzor, so I’m probably going in the wrong direction with this xD

Okay, I’ve got one for you, but you’ll probably have to make a few modifications. Since you’ll want to raycast to the ground below you to check how high up the hoverboard should be. Just figured I’d give you some starting ground.

(Code was checked slightly before posting.)

using UnityEngine;
using System.Collections;

public class HoverBoard : public MonoBehaviour
{
   public float HeightIncr = .01f;
   public float fOrigin = 0.0f;
   public float fHeightPosition = 2.0f;
   public bool goingUp = true;

  void Start()
  {
  }

  void Update()
  {

     if(goingUp == true)
      {
           if(transform.position.y => fHeightPosition)
            {
               goingUp = false;
            }
            else
            {
              transform.position.y += HeightIncr;
            }
      }
      else
      {
	   if(transform.position.y =< fOrigin)
	   {
             goingUp = true;
           }
           else
           {
             transform.position.y -= HeightIncr;
           }
      }
  }
}

Some Time.deltaTime would be appreciated :smile: