Hey guys! Since you guys were of such great help before I thought I’d ask for some more help! Anyway, I have a Raycast in my game for my player’s machine gun. Everything went fine, but my issue, however, are the Particle Emitters. When the Fire button is held down, the muzzleflash should go off; however, it simply doesn’t. Everything in the public variables are in place (like the emitters), and they work in the editor. Just not in conjunction with the script.
Here’s the first block:
void Start ()
{
WallSparks.emit = false;
MuzzleFlashEMITTER.emit = false;
}
// Update is called once per frame
void Update ()
{
if(Input.GetButton("Fire1"))
{
MuzzleFlashEMITTER.Emit();
RayShoot();
}
}
The same goes for the sparks that are supposed to fly out when it makes contact with a rigidbody. As shown below:
void RayShoot ()
{
RaycastHit hit;
Vector3 DirectionRay = transform.TransformDirection (Vector3.right);
Debug.DrawRay (transform.position, DirectionRay * Range, Color.yellow);
if(Physics.Raycast(transform.position, DirectionRay, out hit, Range))
{
if(hit.rigidbody)
{
if(WallSparks)
{
WallSparks.Emit();
WallSparks.transform.position = hit.point;
WallSparks.transform.localRotation = Quaternion.FromToRotation(Vector3.forward, hit.normal);
}
hit.collider.SendMessageUpwards ("ApplyDamage", Damage, SendMessageOptions.DontRequireReceiver);
}
}
}
As with my previous post, I will post the entire source file below. It’s just really strange. I’ve been able to re-purpose the Emitter script for other stuff but not this. Must be something obvious I just missed! Anyway, Please & Thank-You guys!
1894495–121978–RayShot.cs (1.1 KB)