using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawner : MonoBehaviour
{
public GameObject[Spawner1]
public float speed;
public float speedIncrease;
private void Update()
{
speed += speedIncrease * Time.deltaTime;
}
public void SpawnWave()
{
int rand = Random.Range(0, blocklines.Lenght);
Instantiate(blocklines[rand], transform.position, Quaternion.identity);
}
}
I’m sure you realize asking in a forum how to fix every compilation error you find is going to get you nowhere fast (because believe me, you’re going to get lots of these).
There are 2 problems here:
-
You forgot the semicolon at the end of line 8.
-
Line 8 is wrong because:
-
It’s a definition that only specifies the type (
GameObject[Spawner1]
), you need to provide a name for the member (in this case provably blocklines). -
Sorry about this part because I got it wrong in the previous post. When you define an array in C# you don’t need to specify the size (
GameObject[ ] blocklines
). In this case you’ll be able to configure the dimension in the Unity inspector. If you actually want to specify the size you need to do it like this:GameObject[ ] blocklines = new GameObjects[NumberOfElements]
thank you