using Synty.AnimationBaseLocomotion.Samples; using UnityEngine; public class Pickup : MonoBehaviour { public enum PickupType { Health, Strength, StunBomb } [Header("Pickup Settings")] public PickupType type; public float rotationSpeed = 90f; // Gives it that classic video game spin [Header("Health Settings")] public int healAmount = 50; public GameObject healthVFX; [Header("Strength Settings")] public float strengthMultiplier = 2.0f; // Doubles damage and knockback public float strengthDuration = 10f; public GameObject strengthVFX; [Header("Stun Settings")] public float stunRadius = 8f; public float stunDuration = 5f; public LayerMask enemyLayer; public GameObject stunVFX; void Update() { // Slowly rotate the pickup to make it visually obvious transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime); } void OnTriggerEnter(Collider other) { // Make sure your Player Prefab has the "Player" Tag assigned at the very top of its Inspector! if (other.CompareTag("Player")) { ApplyPickupEffect(other.gameObject); // Optional: Play a sound or spawn a particle effect here before destroying Destroy(gameObject); // Remove the pickup from the world } } private void ApplyPickupEffect(GameObject player) { switch (type) { case PickupType.Health: PlayerHealth health = player.GetComponent(); if (health != null) health.Heal(healAmount); Instantiate(healthVFX, player.transform.position + Vector3.up * 0.1f, player.transform.rotation, player.transform); break; case PickupType.Strength: SyntyPlayerCombat combat = player.GetComponent(); if (combat != null) combat.ApplyStrengthBuff(strengthMultiplier, strengthDuration); Instantiate(strengthVFX, transform.position, transform.rotation); break; case PickupType.StunBomb: ExecuteStunBomb(transform.position); Instantiate(stunVFX, transform.position, transform.rotation); break; } } private void ExecuteStunBomb(Vector3 center) { Collider[] hitEnemies = Physics.OverlapSphere(center, stunRadius, enemyLayer); foreach (Collider enemyCollider in hitEnemies) { EnemyAI enemy = enemyCollider.GetComponentInParent(); if (enemy != null) { enemy.ApplyStun(stunDuration); } } } void OnDrawGizmosSelected() { if (type == PickupType.StunBomb) { Gizmos.color = Color.cyan; Gizmos.DrawWireSphere(transform.position, stunRadius); } } }