Need help in making a integer or variable I can edit for how many lasers I want spawned and at what interval

`public class SpawnLaser : MonoBehaviour
{
public GameObject Laser;

void Start()
{
    
    InvokeRepeating("SL", 2f, 2f);
}

void SL()
{
    Instantiate(Laser, transform.position, Laser.transform.rotation);
}

}`
I dont know how to make this work please help

The parts you need will be:

  • a public integer variable
  • a loop to count and spawn based on that variable

Which of those two parts of this task are you struggling with?

This is a great strategy to work on these sorts of things:

Imphenzia: How Did I Learn To Make Games:

Two steps to tutorials and / or example code:

  1. do them perfectly, to the letter (zero typos, including punctuation and capitalization)
  2. stop and understand each step to understand what is going on.

If you go past anything that you don’t understand, then you’re just mimicking what you saw without actually learning, essentially wasting your own time. It’s only two steps. Don’t skip either step.