How would I go about scripting a delay for a raycast? Initially how would I change this script so that instead of it shooting the raycast every frame I can change the tempo of it?
function Update(){ if (Input.GetButton("Fire1")){ Shoot(); } } var shotSound: AudioClip; var bloodPrefab: GameObject; var sparksPrefab: GameObject; function Shoot(){ if (shotSound) audio.PlayOneShot(shotSound); var hit: RaycastHit; if (Physics.Raycast(transform.position, transform.forward, hit)){ var rot = Quaternion.FromToRotation(Vector3.up, hit.normal); if (hit.transform.tag == "Enemy"){ if (bloodPrefab) Instantiate(bloodPrefab, hit.point, rot); hit.transform.SendMessage("ApplyDamage", 20, SendMessageOptions.DontRequireReceiver); } else { if (sparksPrefab) Instantiate(sparksPrefab, hit.point, rot); } } }