Towers stop firing

I got the towers to shoot at the closets enemy, but they stop shooting after a certain amount of time. I made sure the particle system is looping, and I’m not sure why they would stop. In the video provided, I noticed the second enemy disappearing prematurely, and I’m not sure why. There are no errors logged. I believe we don’t disabled the GameObject in the script. Any ideas would be nice. Thanks in advance.

I cleaned up my console, and now I’m seeing the enemy spawn script calls twice… not sure why.

void Start()
{
    StartCoroutine(EnemySpawn());
}

IEnumerator EnemySpawn ()
{
    while (true)
    {
        Instantiate(enemy, transform.position, Quaternion.identity);
        print("Spawned Enemy");
        yield return new WaitForSeconds(enemyWait);
    }
}

Hi,

Which version of Unity do you use?

2018.3.2f1

Is the editor the culrpit? I like my prefabs in prefabs :frowning:

I fear it is. The prefab system has changed in 2018.3. If you prefer the old one, downgrade to 2018.2.
Did you upgrade Unity or did you start this project with 2018.3?

Bummer. I started this project with 2018.3. Oh well, thanks for the feedback.

Were the arrows visible before? Maybe you could try to drag one of your towers into the assets folder to see if nested prefabs work.

You mean the arrow icon on the prefab in the Hiearchy? Yes. Ever since I nested Rick’s voxel prefab into the tower prefab.

Great. I asked because the arrow disappeared for another student. I just wanted to make sure it’s not a Unity bug in your case.

Could you please zip your project, upload it onto the internet (e.g. Dropbox, OneDrive) and share a link here? I’d like to take a look into it. And please delete the Library folder from the zip. Sound files are not necessary either.

Thanks for sending me the zip. I’m replying here so other students can benefit from my answer, too.

I use Unity 2018.3.0f2, and I hopefully found a solution. Try to set the Culling Mode to “Always Simulate”. Does that fix the issue?

Of course. Glad if other people can benefit out of this discussion.

Setting the culling mode helped a bit. The particles don’t permanently stop at least. However the enemies health points get reduced to 1 after that blip. Clearly the enemy spawner somehow get’s called twice.

Did you change the health of the enemy in the scene? Is the health value assigned to your prefab, too?

That did it. It was assigned. Weird thing is if the health is low it works fine. But if I put the health high, the blip still happens and the enemy health is low again.

I just didn’t serialized the health points as a band aid solution. It’s weird the enemy spawner would trigger twice. It really is the editor.

That’s what was confusing me in your project, too. When I disabled the EnemySpawner component, the enemies kept spawning. I decided to ignore it.


See also:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms