Obstacles and enemies both vary in size upon spawning

This commit is contained in:
Gregory Campbell
2020-07-11 11:01:39 -04:00
parent b0b4c2b378
commit 1016b2065a
+7 -4
View File
@@ -34,8 +34,9 @@ public class GMScript : MonoBehaviour
if(obstacleTime > obstacleSpawnTime)
{
Instantiate(obstacle, new Vector2(Random.Range(-8.0f, 8.0f), Random.Range(-4.0f, 4.0f)),
GameObject newObstacle = Instantiate(obstacle, new Vector2(Random.Range(-8.0f, 8.0f), Random.Range(-4.0f, 4.0f)),
Quaternion.Euler(0,0,Random.Range(0.0f, 360.0f)));
newObstacle.transform.localScale = new Vector2(Random.Range(1.0f, 8.0f), 1.0f);
obstacleSpawnTime = Random.Range(5.0f, 15.0f);
obstacleTime = 0.0f;
}
@@ -43,8 +44,10 @@ public class GMScript : MonoBehaviour
if(enemyTime > enemySpawnTime)
{
Instantiate(enemy, new Vector2(Random.Range(-8.0f, 8.0f), Random.Range(-4.0f, 4.0f)),
GameObject newEnemy = Instantiate(enemy, new Vector2(Random.Range(-8.0f, 8.0f), Random.Range(-4.0f, 4.0f)),
Quaternion.identity);
float scaleChange = Random.Range(0.5f, 1.5f);
newEnemy.transform.localScale = new Vector2(scaleChange, scaleChange);
enemySpawnTime = Random.Range(5.0f, 15.0f);
enemyTime = 0.0f;
}
@@ -61,8 +64,8 @@ public class GMScript : MonoBehaviour
spawn = new Vector2(Random.Range(-8.0f, 8.0f), Random.Range(-4.0f, 4.0f));
if((spawn.x > playerPos.position.x + 2 || spawn.x < playerPos.position.x - 2)
&& (spawn.y > playerPos.position.y + 2 || spawn.y < playerPos.position.y - 2))
if((spawn.x > playerPos.position.x + 4 || spawn.x < playerPos.position.x - 4)
&& (spawn.y > playerPos.position.y + 4 || spawn.y < playerPos.position.y - 4))
{
valid = true;
}