Classic Tetris like game - Falling one unity/second?

Hi guys, I'm still working on my Tetris game and I'm on thin ice again.

I've made a fall script that looks like this:

var target : Transform

function Update () {
    transform.Translate(Vector3(0,-1,0) * Time.deltaTime, Space.World);
}

Now what this does is move the 'target' smoothly down, but the action I want is the ticky feeling, more like one unit/sec down the -y axis.

I hope you can bare with me as I'm still learning.

This is all you need (and tested too!)

Javascript:

function Start () {
    while (true) {
        yield WaitForSeconds(1);
        transform.Translate(0,-1,0);
    }
}

C#:

using UnityEngine;
using System.Collections;

public class BlockDrop : MonoBehaviour {

    IEnumerator Start() {
        while (true) {
            yield return new WaitForSeconds(1);
            transform.Translate(0,-1,0);
        }
    }

}

This code sample should help you to be able to set your own tick values which should help when u want to play the levels on different speeds, like the higher levels. My clock works similarly to the waitforseconds mechanism. It's just a different road.

private bool canStartClock;
private float timer;
private float maxTime;
private float baseTimerValue;

void Start()
{
    canStartClock = false;
    timer = 1.5f;
    baseTimerValue = timer;
}

void Update()
{
    //if (SomeEventHappened)
    //{
    //    canStartClock = true;
    //}

    if (canStartClock)
    {
        //start the clock
        StartClock();
    }
    else
    {
        //reset the clock
        canStartClock  = false;
        timer = baseTimerValue;
    }
}

public void StartClock()
{
    if (timer > maxTime)
    { 
        //TIME IS UP!
        //Respond to the time being up code
    }
    else
    {
        //STILL WAITING
        timer += Time.deltaTime;
    }

}

This of course would be much better if it simply accepted a time value and returned a bool. However I wanted to help you out quickly right now, I hope this will suffice. Feel free to use the whole sample, I wrote it just for this Q&A anyway. Removing the core code from the clock is a very important thing to do, making it static and using it as library even better. Keep it all encapsulated, this is just a demo to help show a clock tick.

Try using yield instead of plainly dropping.

I don't like yield so here is my version:

float nextStepTimestamp;

void Start()
{
    // Next time we fall.
    nextStepTimestamp = Time.realtimeSinceStartup + 1;
}

void Update()
{
    if ( nextStepTimestamp <= Time.realtimeSinceStartup )
    {
        transform.Translate(Vector3(0,-1,0), Space.World);
        nextStepTimestamp = Time.realtimeSinceStartup + 1;
    }
}