- Home /
Troubleshooting the spawn mechanic in a puzzle game
The questions I found when making a specific game like puyo puyo, or columns, did not match the problem that I have. Now this is just something that I want to make from the ground up, and make a puzzle game that has the columns puzzle piece mechanic, but plays in a small grid and plays like puyo puyo. But right now I'm having trouble making the spawner, the component that places the pieces on the board. I have only two errors in the spawner script. Here's what I have so far:
public void SpawnNewGroup() { int i = Random.Range(0, Groups.Length); Instantiate(Groups[i], Transform.position, Quaternion.identity); }
The parts in bold are the errors I have according to the Visual. How can I fix this without making it worse, or starting back at square one?
And to explain that first part, the questions I found beforehand are mostly jigsaw puzzles and stuff, not the games we all know.
Answer by swanne · Jun 16, 2019 at 10:55 AM
Hey,
I did a similar thing with spawning waves of enemies in a spaceshooter game. The concept sounds similar. I used a coroutine to control the timing bewteen spawns too. Check out the below and hope it can help a bit;
IEnumerator SpawnWaves()
{
yield return new WaitForSeconds(startWait);
while (true)
{
for (int i = 0; i < Groups.Length; i++)
{
Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
Quaternion spawnRotation = Quaternion.identity;
Instantiate(puzzlePiece, spawnPosition, spawnRotation);
yield return new WaitForSeconds(spawnWait);
}
yield return new WaitForSeconds(waveWait);
}
}
Your answer
Follow this Question
Related Questions
Sprite Match Mechanic 0 Answers
How To Match Puzzle League Style 0 Answers
How do I force the player to press buttons in order? 2 Answers
Puzzle piece rotation 0 Answers
Puzzle Piece Match Mechanic 1 Answer