JS

// Starting in 2 seconds.
// a projectile will be launched every 0.3 seconds
var projectile : Rigidbody;
InvokeRepeating("LaunchProjectile", 2, 0.3);
function LaunchProjectile () {
instance = Instantiate(prefab);
instance.velocity = Random.insideUnitSphere * 5;
}

 

C#

using UnityEngine;
using System.Collections;

public class NewBehaviourScript : MonoBehaviour {
// Use this for initialization
void Start () {
   InvokeRepeating("LaunchProjectile", 1,5);//1秒后调用LaunchProjectile () 函数,之后每5秒调用一次
}

// Update is called once per frame
void Update () {

}
void LaunchProjectile () {
   print("hello");
}
}

相关文章:

  • 2022-01-07
  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2021-10-04
  • 2022-01-07
  • 2021-11-16
  • 2022-12-23
猜你喜欢
  • 2020-03-01
  • 2021-09-21
  • 2021-12-14
  • 2022-03-01
  • 2022-12-23
  • 2021-09-11
相关资源
相似解决方案