Advertisement
johnnygoodguy2000

CoinGenerator.cs

Apr 7th, 2024 (edited)
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.87 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class CoinGenerator : MonoBehaviour
  6. {
  7.     public ObjectPooler coinPool;
  8.  
  9.     public float distanceBetweenCoins;
  10.  
  11.     public void SpawnCoins(Vector3 spawnPosition)
  12.     {
  13.         GameObject coin1 = coinPool.GetPooledObject();
  14.         coin1.transform.position = spawnPosition;
  15.         coin1.SetActive(true);
  16.  
  17.         GameObject coin2 = coinPool.GetPooledObject();
  18.         coin2.transform.position = new Vector3(spawnPosition.x + distanceBetweenCoins, spawnPosition.y, spawnPosition.z);
  19.         coin2.SetActive(true);
  20.  
  21.         GameObject coin3 = coinPool.GetPooledObject();
  22.         coin3.transform.position = new Vector3(spawnPosition.x + 2 * distanceBetweenCoins, spawnPosition.y, spawnPosition.z); // Adjusted position for the third coin
  23.         coin3.SetActive(true);
  24.     }
  25. }
  26.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement