Paste
Of Code


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
using UnityEngine;

public class WeaponPickup : MonoBehaviour
{
    public string weaponName;
    public GameObject weaponPrefab;

    private void OnTriggerEnter(Collider other)
    {
        Debug.Log($"🔥 {other.name} entered the weapon pickup trigger!");

        if (other.CompareTag("Player"))
        {
            Debug.Log($"✅ Player collided with {weaponName} pickup!");

            WeaponManager weaponManager = other.GetComponent<WeaponManager>();
            if (weaponManager != null)
            {
                Debug.Log($"🔫 Attempting to unlock {weaponName}...");
                weaponManager.UnlockWeapon(weaponName, weaponPrefab);
                Debug.Log($"✅ {weaponName} unlocked successfully!");
                Destroy(gameObject);
            }
            else
            {
                Debug.LogError("❌ WeaponManager not found on Player!");
            }
        }
    }
}

Toggle: theme, font