# InvokeRepeating(string, float, float)

> Invokes the specified method after a specified delay, then repeatedly at the specified rate.

## Definition

* **Type:** Method
* **Namespace:** [UnityEngine](/engine/6000.5/script-reference/unityengine.md)
* **Assembly:** UnityEngine.CoreModule

```csharp
public void InvokeRepeating(string methodName, float time, float repeatRate)
```

### Parameters

**** (\[string]\(https\://learn.microsoft.com/dotnet/api/system.string)): The name of a method to invoke.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Time to wait in seconds before the first invocation.**** (\[float]\(https\://learn.microsoft.com/dotnet/api/system.single)): Interval in seconds between method invocations.

### Remarks

To cancel `InvokeRepeating`, use [MonoBehaviour.CancelInvoke()](/engine/6000.5/script-reference/unityengine/monobehaviour/cancelinvoke.md).

The `time` and `repeatRate` parameters depend on [Time.timeScale](/engine/6000.5/script-reference/unityengine/time/timescale.md). For example, a [Time.timeScale](/engine/6000.5/script-reference/unityengine/time/timescale.md) of 2 effectively halves the real-time values of `time` and `repeatRate`, while a [Time.timeScale](/engine/6000.5/script-reference/unityengine/time/timescale.md) of 0.5 doubles them. If [Time.timeScale](/engine/6000.5/script-reference/unityengine/time/timescale.md) is 0, then the `method` is never invoked.

You can't change the value of the `repeatRate` interval while `InvokeRepeating` is running. You must cancel and re-invoke to change it.

### Examples

```csharp
using UnityEngine;
using System.Collections.Generic;

// After an initial 2 second wait, launch a projectile every 0.3 seconds

public class ExampleScript : MonoBehaviour
{
    public Rigidbody projectile;

    void Start()
    {
        InvokeRepeating(nameof(LaunchProjectile), 2.0f, 0.3f);
    }

    void LaunchProjectile()
    {
        Rigidbody instance = Instantiate(projectile);

        instance.velocity = Random.insideUnitSphere * 5;
    }
}
```
