using System.Collections; using System.Collections.Generic; using UnityEngine; public class CoinGame : MonoBehaviour { [SerializeField] private GameObject coin; private const int MAX_COIN = 10; // Start is called before the firsst frame update void Start() { System.Random random = new System.Random(); // Create Coin for(int i = 0; i < MAX_COIN; i++) { var go = Instantiate( coin, new Vector3( transform.position.x, transform.position.y+3, transform.position.z ), transform.rotation ); // random int positionX = random.Next(-50, 50); int positionZ = random.Next(-50, 50); go.GetComponent().position = new Vector3( positionX, go.GetComponent().position.y, positionZ ); } } }