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.Invoke

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

Description

Invokes the method methodName in time seconds.

	// Launches a projectile in 2 seconds

var projectile : Rigidbody;

Invoke("LaunchProjectile", 2);

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