Looking for a simple Score Multiplier.

Hi there,

I’m looking for a score multiplier that works like this:

  • When you hit/collide with an object,
    you get the regular 10 points. (see script)

  • When you hit the next object within
    4 seconds you get 50 points.

  • When you hit the next object within a fresh 4
    (same amount) seconds you get 100
    points.

  • When you hit the next object within
    the amount of time something
    instantiates. End of it.

I looked into a lot of tutorials and other topics and tried almost everything with no result (mainly due to programming experience as a beginner → I understand how it works when I see it and alt it, but cannot create it from scratch).

Can someone please please help me? Or give me a push in the right direction? Like should I use a coroutine for it or just a time.deltatime function?

public float scoreValue = 10.0f;				
private GameController1 gameController;		

void OnTriggerEnter(Collider other)
{

	if (other.tag == "Player") 
	{
		other.gameObject.BroadcastMessage ("TakeDamage", damage); // damage to player script.

		gameController.AddScore (scoreValue); // score to gamecontroller script
	}
}

Thanks big time again @PersianKiller for your solution! This is perfect! So glad it works. Here’s the final result (will tweak the amount of extra score per megaScore later):

private float megaScore;
private float score;

public void AddScore (float newScoreValue)
{
	if(megaScore==0)
	{
		score += newScoreValue;
		megaScore=1;
		StartCoroutine ("MultiScoreThing");
	}
	else if(megaScore==1)
	{
		score += newScoreValue + 1;
		megaScore=2;
		StopCoroutine ("MultiScoreThing");
	}

	else if(megaScore==2)
	{
		score += newScoreValue + 2;
		megaScore=3;
		StopCoroutine ("MultiScoreThing");
	}

	UpdateScore ();
	StartCoroutine ("MultiScoreThing");
}

IEnumerator MultiScoreThing ()
{
	yield return new WaitForSeconds (4);
	megaScore = 0;
}

hey ,I guess you just need a simple timer like this

public int Score;

public void addScore(int a){

	if(megaScore==0){

		Score += a;
	}
	else if(megaScore==1){

		Score += a * 10;
	}
	StartCoroutine ("Multiplier");
}

public IEnumerator Multiplier(){
	
	yield return new WaitForSeconds (4);
	megaScore = 0;
}