score script, x2 for 10 seconds

Hi all, I have this score script:

function OnTriggerEnter(enterer : Collider) 
{
    if (enterer.collider.gameObject.CompareTag("Bullet"))
    {
        Debug.Log("Score!");
        Scorecounter.Counter ++;
    }
}

and this score counter script:

static var Counter : int = 0;

function Update () 
{    
    guiText.text = "Score: " + Counter;
}  

what I would like to do is have a collectable item, and when the player collides with it, it increases the score x2 (eg, if you usually get 10pts for breaking a block you would get 20pts) and this happens for a 10 second period after collecting the item then scoring resets back to normal.

I was thinking if I put a function OnTriggerEnter(enterer : Collider)
{
if (enterer.collider.gameObject.CompareTag(“item”))
{

and then somehow make the score go up x2. I don’t know what to add to my score script to do this any pointers?

You need a a var similar to your counter which multiply the reward, 1 in your case. Something like Scorecounter.Counter += 1 * Scorecounter.Multiplicator;

Then, you can increase that multiplicator or decrease it. You’ll need Invoke or a coroutine for the 10 seconde delay. To make seems clearer :

score script : The GUI part

static var Counter : int = 0;
static var Multiplicator : int = 1;

function Update () 
{    
    guiText.text = "Score: " + Counter;
}

brick script : The score is increased

private const var BASE_REWARD  : int = 1; // That way you know what it represent.

function OnTriggerEnter( enterer : Collider ) 
{
    if( enterer.collider.gameObject.CompareTag("Bullet") )
    {
        Debug.Log("Score!");
        // This could also be a static function.
        Scorecounter.Counter += BASE_REWARD * Scorecounter.Multiplicator;
    }
}

powerup script : Make every brick give +2 instead of +1

function OnTriggerExit( enterer : Collider ) 
{
    //this is the powerup hitting player
    // Are you sure the player has the tag "scoremultiplyer_powerup" ?
    if (enterer.collider.gameObject.CompareTag("scoremultiplyer_powerup"))
    {
        Scorecounter.Multiplicator++;
        // Note that if this gameObject is destroyed before those 10 seconds,
        // the function won't be called.
        Invoke( "DecreaseInXSeconds", 10.0 );
    }
}

function DecreaseInXSeconds(){
    // Make sure we don't have a null multiplicator.
    Scorecounter.Multiplicator = Mathf.Max( 1, Scorecounter.Multiplicator-1 );
}