Hey guys, could you help me out, I can’t figure out what should I do.
The blocks that are falling from the red spawn points should increase the score after they pass the box collider. I want them to increase it by 1, instead of 2.
[123567-untitled.png*|123567]
Here is also the code.
public class ScoreManager : MonoBehaviour {
public Text scoreText;
public float scoreCount;
void Update ()
{
scoreText.text = scoreCount.ToString ();
}
void OnTriggerExit2D ()
{
scoreCount = scoreCount + 1;
}
}
Also what I wanted to do for example if the score is equal to 20 to start spawning blocks from the blue spawnpoints and stop spawning them from the red ones.
That’s the blockspawner script:
public class BlockSpawner2 : MonoBehaviour
{
public Transform[] spawnPoints;
public GameObject block;
public float timeBetweenWaves = 1f;
private float timeSpawner = 2f;
void Update ()
{
if (Time.time >= timeSpawner)
{
SpawnBlocks ();
timeSpawner = Time.time + timeBetweenWaves;
}
}
void SpawnBlocks ()
{
int randomIndex = Random.Range (0, spawnPoints.Length);
for (int i = 0; i < spawnPoints.Length; i++)
{
if (randomIndex != i)
{
Instantiate (block, spawnPoints*.position, Quaternion.identity);*
-
}*
-
}*
- }*
}
[123568-untitled1.png|123568]*
,