I have this script attached to my FPController
var cam : Transform;
var playerTransform : Transform;
function Update () {
var ray : Ray = new Ray(cam.position, cam.forward);
var hit : RaycastHit;
if(Physics.Raycast (ray, hit, 1))
{
if (hit.transform.tag == 'Move')
{
if (Input.GetButtonDown ("Fire1"))
{
playerTransform.position.y = transform.position.y+2.5;
transform.Translate(Vector3.forward * 1);
}
}
}
}
Which if the player is next to an object with tag of Move if they press the mouse button they move up 2.5 and move on top of the object. Currently this happens all in one frame, but id like to make it so he moves up gradually, maybe make the move last 1 second.
How would I do this?