InvokeRepeating not working

Hi guys,

So I’m trying to make the speed of my shuriken increase by 2 after 30 seconds, and then every 30 seconds after that. From what I read in the documentation, this should be how it’s done?

private Rigidbody2D rb2d;
public float speed = 10f;
public GameObject DownShuriken;
public static int livess = 2; 
void Start ()
{
	rb2d = GetComponent<Rigidbody2D> ();
}
void Update () 
{
	rb2d.AddForce(Vector2.down*speed);
	InvokeRepeating ("IncreaseSpeed", 30, 30f);
}
void SpawnShurikenDown()
{
	Vector3 RandomSpawn = new Vector3 (Random.Range (-9.1F, 9.1F), Random.Range (5.04F, 5.04F),1F);
	Instantiate (DownShuriken, RandomSpawn, Quaternion.identity);
}

void OnTriggerExit2D(Collider2D other)
{
	if(other.gameObject.CompareTag ("BottomBackground"))
	{
		SpawnShurikenDown ();
		Destroy (DownShuriken);
	}
}
void IncreaseSpeed ()
{
	speed = speed + 2f;
}

}

After 30 seconds, the speed of the shuriken does not change. A Debug.LogError (speed) does nothing inside the function IncreaseSpeed when put beneath the line where I change the speed.

Maybe update was reset InvokeRepeating?

If so. You can try alternative.

By replace

void Update () 
{
    rb2d.AddForce(Vector2.down*speed);
    InvokeRepeating ("IncreaseSpeed", 30, 30f);
}

And With this script

public float lastTime;
void Update () 
{
    rb2d.AddForce(Vector2.down*speed);
    if (Time.time > lastTime)
    {
	    lastTime = Time.time + 30;
	    IncreaseSpeed();
    }
}