I’ve been trying to get this script to shoot then wait before shooting again.
When I use this script:
#pragma strict
var Effect : Transform;
var TheDammage = 100;
function Update () {
var hit : RaycastHit;
var ray : Ray = Camera.main.ScreenPointToRay(Vector3(Screen.width*0.5, Screen.height*0.5, 0));
if (Input.GetMouseButton(0))
{
if (Physics.Raycast (ray, hit, 100))
{
var particleClone = Instantiate(Effect, hit.point, Quaternion.LookRotation(hit.normal));
Destroy(particleClone.gameObject, 2);
hit.transform.SendMessage("ApplyDammage", TheDammage, SendMessageOptions.DontRequireReceiver);
}
}
}
It just repeats the script pretty quickly. I’ve tried putting “yield WaitForSeconds (0.05);” at the end of the script but when I try that it just doesn’t shoot anymore. Can someone please help me? It’d be much appreciated.