InputCooldown.cs
using System.Collections; using System.Collections.Generic; using UnityEngine; public class InputCooldown : MonoBehaviour { public float cooldownTime = 0f; private bool isCooldown = false; private void Update() { if (Input.GetMouseButton(0) && !isCooldown) { StartCoroutine(Cooldown()); SpawnSphere(); } } private IEnumerator Cooldown() { isCooldown = true; yield return new WaitForSeconds(cooldownTime); isCooldown = false; } private void SpawnSphere() { GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere); Vector3 mousePos = new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10); sphere.transform.position = Camera.main.ScreenToWorldPoint(mousePos); sphere.AddComponent<Rigidbody>(); GameObject.Destroy(sphere, 5); } }