Created
January 4, 2020 03:32
-
-
Save gremito/6b6a1a5cf081d39c22a2d3768ffac617 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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<Transform>().position = new Vector3( | |
positionX, | |
go.GetComponent<Transform>().position.y, | |
positionZ | |
); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment