CoinManagement.cs 819 B

1234567891011121314151617181920212223242526272829
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CoinManagement : MonoBehaviour
  5. {
  6. public GameObject coin = null;
  7. // Start is called before the first frame update
  8. void Start()
  9. {
  10. Vector3 start = new Vector3(298.9206f, 0.5000005f, -0.1749458f);
  11. Vector3 finish = new Vector3(400f, 0.5000005f, -0.1749458f);
  12. PlaceCoins(start, finish, 20);
  13. }
  14. // Update is called once per frame
  15. void Update()
  16. {
  17. }
  18. void PlaceCoins(Vector3 start, Vector3 finish, float number)
  19. {
  20. float space = System.Math.Abs(start.x - finish.x)/number;
  21. for (int i=0; i < number; ++i)
  22. {
  23. Instantiate(coin, new Vector3(start.x + i*space, start.y, start.z), Quaternion.Euler(0f, 0f, 90f));
  24. }
  25. }
  26. }