Browse Source

Add small demo script for automatically cretaing coins

Till Steinert 2 years ago
parent
commit
c7e8379d18
1 changed files with 29 additions and 0 deletions
  1. 29 0
      Assets/Coin/CoinManagement.cs

+ 29 - 0
Assets/Coin/CoinManagement.cs

@@ -0,0 +1,29 @@
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class CoinManagement : MonoBehaviour
+{
+    public GameObject coin = null;
+    // Start is called before the first frame update
+    void Start()
+    {
+        Vector3 start = new Vector3(298.9206f, 0.5000005f, -0.1749458f); 
+        Vector3 finish = new Vector3(400f, 0.5000005f, -0.1749458f);
+        PlaceCoins(start, finish, 20);
+    }
+
+    // Update is called once per frame
+    void Update()
+    {
+    }
+
+    void PlaceCoins(Vector3 start, Vector3 finish, float number) 
+    {
+        float space = System.Math.Abs(start.x - finish.x)/number;
+        for (int i=0; i < number; ++i) 
+        {
+            Instantiate(coin, new Vector3(start.x + i*space, start.y, start.z), Quaternion.Euler(0f, 0f, 90f));
+        } 
+    } 
+}