Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

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);
            }
        }
Comment

PREVIOUS NEXT
Code Example
Csharp :: even number checker in c# 
Csharp :: c# exit application 
Csharp :: how to start a coroutine in c# 
Csharp :: unity rotate around pivot c# 
Csharp :: wpf fixed size window 
Csharp :: string to list c# 
Csharp :: unity create button with parameter 
Csharp :: sum of digits in c# 
Csharp :: how to convert a bitmap to a base64 string c# xamarin universal 
Csharp :: get current directory cosmos 
Csharp :: making beep voice in c# 
Csharp :: c# winforms tooltip 
Csharp :: c# how to output in between 0 - 100 in an int array 
Csharp :: unity temperature to colour 
Csharp :: c# check if string is directory 
Csharp :: c# null check can be simplified 
Csharp :: c# winforms textbox readonly 
Csharp :: c # c^b 
Csharp :: base64 string to byte array c# 
Csharp :: uni valued tree 
Csharp :: c# string newline 
Csharp :: get enum int by name 
Csharp :: dictionary c# 
Csharp :: C# int.parse input string wasnt in correct format 
Csharp :: unity remove parent 
Csharp :: debug.log unity 
Csharp :: key press up unity 
Csharp :: unity 2d joystick controls 
Csharp :: unity dictionary check if key exists 
Csharp :: c# how to terminate console application 
ADD CONTENT
Topic
Content
Source link
Name
1+5 =