I have two scripts; on is a shooting script and the other is bullet damage. The shooting script at the moment shoots rigidbody bullets. Is there a way I can change the shooting script to shoot raycast bullets instead of rigidbody bullets and then change the damage script to accommodate the raycast bullets?
shooting script:
RequireComponent(AudioSource);
var audioSource: AudioSource;
var Projectile : Rigidbody;
var ProjectileSpeed : int = 10;
var FireRate : float = 10; // The number of bullets fired per second
var lastfired : float; // The value of Time.time at the last firing moment
var gunshot : AudioClip;
var muzzleflash :Transform;
function Start() {
audioSource = GetComponent.<AudioSource>();
}
function Update ()
{
if (Input.GetAxis("Fire1")>0f)
{
if (Time.time - lastfired > 1 / FireRate)
{
lastfired = Time.time;
var clone : Rigidbody;
clone = Instantiate(Projectile, transform.position, transform.rotation);
clone.velocity = transform.TransformDirection (Vector3.forward * ProjectileSpeed);
audioSource.PlayOneShot(gunshot, 0.7F);
Instantiate (muzzleflash,transform.position,transform.rotation);
}
}
}
bullet damage script:
var dmg:float = 20;
function OnTriggerEnter(hit:Collider){
if(hit.tag == "Player"){
hit.transform.SendMessage("Damage",dmg);
}
}