I still didn’t understand , can any one explain me with diagrams
{
switch (side)
{
case 0:
// Left
spawnPoint.x = 0;
spawnPoint.y = Random.value;
direction = new Vector2(1f, Random.Range(-1f, 1f));
break;
case 1:
// Right
spawnPoint.x = 1;
spawnPoint.y = Random.value;
direction = new Vector2(-1f, Random.Range(-1f, 1f));
break;
case 2:
// Bottom
spawnPoint.x = Random.value;
spawnPoint.y = 0;
direction = new Vector2(Random.Range(-1f, 1f), 1f);
break;
case 3:
// Top
spawnPoint.x = Random.value;
spawnPoint.y = 1;
direction = new Vector2(Random.Range(-1f, 1f), -1f);
break;
}
Vector3 worldSpawnPoint = mainCamera.ViewportToWorldPoint(spawnPoint);
worldSpawnPoint.z = 0;
GameObject selectedAsteroid = asteroidPrefabs[Random.Range(0, asteroidPrefabs.Length)];
GameObject asteroidInstance = Instantiate(
selectedAsteroid,
worldSpawnPoint,
Quaternion.Euler(0f, 0f, Random.Range(0f, 360f)));
Need Help !!
I am conffused as the Tutor is sayingg to take (-1f , 1f ) where if we use ViewPort screen is left with 0,0 to 1,1. then how and why the tutor using Negative 1f ? why this Negative ? please Explain me… m stuck to understand.