Horje
how to spawn coins randomly around the screen unity 2d Code Example
how to spawn coins randomly around the screen unity 2d
    void Start()
        {
            for (int i = 0; i < 10; i++)
            {
                float spawnY = Random.Range
                    (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).y, Camera.main.ScreenToWorldPoint(new Vector2(0, Screen.height)).y);
                float spawnX = Random.Range
                    (Camera.main.ScreenToWorldPoint(new Vector2(0, 0)).x, Camera.main.ScreenToWorldPoint(new Vector2(Screen.width, 0)).x);
     
                Vector2 spawnPosition = new Vector2(spawnX, spawnY);
                Instantiate(banana, spawnPosition, Quaternion.identity);
            }
        }




Csharp

Related
spawn coins randomli in the camera unity 2d Code Example spawn coins randomli in the camera unity 2d Code Example
c# how to append in array Code Example c# how to append in array Code Example
how to update model when database change in entity framework core Code Example how to update model when database change in entity framework core Code Example
save image in C# Code Example save image in C# Code Example
page refresh on button click in c# Code Example page refresh on button click in c# Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
8