Legacy Documentation: Version 4.6(go to latest)
Language: English
  • C#
  • JS
  • Boo

Script language

Select your preferred scripting language. All code snippets will be displayed in this language.

MonoBehaviour.InvokeRepeating

Switch to Manual
public function InvokeRepeating(methodName: string, time: float, repeatRate: float): void;

Description

Invokes the method methodName in time seconds, then repeatedly every repeatRate seconds.

	// Starting in 2 seconds.
	// a projectile will be launched every 0.3 seconds

var projectile : Rigidbody;

InvokeRepeating("LaunchProjectile", 2, 0.3);

function LaunchProjectile () { var instance : Rigidbody = Instantiate(projectile); instance.velocity = Random.insideUnitSphere * 5; }