Advertisement
johnnygoodguy2000

Enemy_Collectable_Drop.cs

Dec 25th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.58 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Enemy_Collectable_Drop : MonoBehaviour
  6. {
  7.    [SerializeField]
  8.    private float chanceOfCollectableDrop;
  9.  
  10.    private Collectable_Spawner _collectableSpawner;
  11.  
  12.    private void Awake()
  13.    {
  14.       _collectableSpawner = FindObjectOfType<Collectable_Spawner>();
  15.    }
  16.  
  17.    public void RandomlyDropCollectable()
  18.    {
  19.     float random = Random.Range(0, 1f);
  20.  
  21.     if (random >= chanceOfCollectableDrop)
  22.     {
  23.         _collectableSpawner.SpawnCollectable(transform.position);
  24.  
  25.     }
  26.    }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement