Particles not appearing on impact, muzzle flash problems?

I'm having a problem with my muzzle flash and particles. I'm following the fps tutorial. I'm trying to use the Sparks prefab as my particles, and I set them as a child object of my gun. Also, I assigned muzzle_flash(the child of my gun) as my muzzle flash animation. However, when I shoot in the game I just get a white box as my muzzle flash. Also, my gun doesn't hit anything. I don't see sparks anywhere. I am using this shooting code for my machine gun:

`var range = 100.0;
var fireRate = 0.05;
var force = 10.0;
var damage = 5.0;
var bulletsPerClip = 40;
var clips = 20;
var reloadTime = 0.5;
private var hitParticles : ParticleEmitter;
var muzzleFlash : Renderer;

private var bulletsLeft : int = 0;
private var nextFireTime = 0.0;
private var m_LastFrameShot = -1;

function Start () {
hitParticles = GetComponentInChildren(ParticleEmitter);

// We don't want to emit particles all the time, only when we hit something.
if (hitParticles)
    hitParticles.emit = false;
bulletsLeft = bulletsPerClip;


function LateUpdate() {
if (muzzleFlash) {
// We shot this frame, enable the muzzle flash
if (m_LastFrameShot == Time.frameCount) {
muzzleFlash.transform.localRotation = Quaternion.AngleAxis(Random.value * 360, Vector3.forward);
muzzleFlash.enabled = true;

        if (audio) {
            if (!audio.isPlaying)
            audio.loop = true;
    } else {
    // We didn't, disable the muzzle flash
        muzzleFlash.enabled = false;
        enabled = false;

        // Play sound
        if (audio)
            audio.loop = false;


function Fire () {
if (bulletsLeft == 0)

// If there is more than one bullet between the last and this frame
// Reset the nextFireTime
if (Time.time - fireRate > nextFireTime)
    nextFireTime = Time.time - Time.deltaTime;

// Keep firing until we used up the fire time
while( nextFireTime < Time.time && bulletsLeft != 0) {
    nextFireTime += fireRate;


function FireOneShot () {
var direction = transform.TransformDirection(Vector3.forward);
var hit : RaycastHit;

// Did we hit anything?
if (Physics.Raycast (transform.position, direction, hit, range)) {
    // Apply a force to the rigidbody we hit
    if (hit.rigidbody)
        hit.rigidbody.AddForceAtPosition(force * direction, hit.point);

    // Place the particle system for spawing out of place where we hit the surface!
    // And spawn a couple of particles
    if (hitParticles) {
        hitParticles.transform.position = hit.point;
        hitParticles.transform.rotation = Quaternion.FromToRotation(Vector3.up, hit.normal);

    // Send a damage message to the hit object          
    hit.collider.SendMessageUpwards("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);


// Register that we shot this frame,
// so that the LateUpdate function enabled the muzzleflash renderer for one frame
m_LastFrameShot = Time.frameCount;
enabled = true;

// Reload gun in reload Time        
if (bulletsLeft == 0)


function Reload () {

// Wait for reload time first - then add more bullets!
yield WaitForSeconds(reloadTime);

// We have a clip left reload
if (clips > 0) {
    bulletsLeft = bulletsPerClip;


function GetBulletsLeft () {
return bulletsLeft;

I had the exaxt same problem when I was following that tutorial so I feel your pain. Here follow this guys video tutorial, it helped me. He's a bit all over the place but gets the job done ;)

I'm experiencing the same problem, the sparks are showing up directly behind the camera no matter where I set it and will maintain a rotation behind the camera so that's why I can't see the sparks.

The other issue is the sparks are only visible in a top down view along the Y-Axis and only appear when firing directly in the sky or sometimes at the ground.

I reviewed the same tutorial, the muzzle flash and the gun you need to manually set the linkage to the associated textures.

I'm currently looking for a solution to the sparks problem, I'm using the default Sparks script that comes with Unity as well to test with.

Anybody have an answer how to fix this?