Train-of-Thought/Assets/Scripts/Dropper.cs
Gerard Gascón 862afc9b7a init
2025-04-24 16:56:52 +02:00

27 lines
665 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Dropper : MonoBehaviour
{
public GameObject ammo;
public void drop(GameObject obj) {
GameObject go = Instantiate(obj);
go.transform.position = gameObject.transform.position;
go.AddComponent<GroundItem>();
go.GetComponent<GroundItem>().selfPrefab = obj;
go.GetComponent<GroundItem>().Radius = 5;
}
public void Ammo()
{
if (Random.value <= 0.5f)
{
Destroy(gameObject);
Instantiate(ammo, transform.position, Quaternion.identity);
}
}
}