Hi! I'm new to Unity and C# and wanted a little help with this little Script of mine.
I'm not quite sure if the title is explicit.
So, what I want to achieve is, basically:
I have an enemy with a Gun attached to it. This gun has an empty GameObject that should be "shooting" prefabs forward and there should be some time (set by myself) between every shot. Ten seconds after the bullet has been shot, it is destroyed.
I have achieved this in my FirstPersonController with right mouse click. But I can't seem to make it automatically.
My question is, if I instantiate the enemies when going through a trigger, how can I make them start shooting automatically after being instantiated, given an X time between shots?
NOTE: The enemies should just shoot forward, not aiming or anything. And they'd have to do it endlessly.
This is what I have so far.
I've also tried using WaitForSeconds, but I just can't seem to entirely get it, though.
If someone could help me with this, I'd be really thankful.
This is very simple. WaitForSeconds is the way to go.
To create your own timed destruction, you could also use WaitForSeconds: