38 lines
1.1 KiB
C#
38 lines
1.1 KiB
C#
![]() |
using System.Collections;
|
||
|
using UnityEngine;
|
||
|
|
||
|
public class ChasePowerUp : MonoBehaviour
|
||
|
{
|
||
|
public float speedBoostAmount = 3f; // How much to boost the speed
|
||
|
public float duration = 5f; // Duration of the speed boost
|
||
|
|
||
|
private void OnTriggerEnter(Collider other)
|
||
|
{
|
||
|
if (other.CompareTag("Player"))
|
||
|
{
|
||
|
ChasePlayerController player = other.GetComponent<ChasePlayerController>();
|
||
|
if (player != null)
|
||
|
{
|
||
|
StartCoroutine(ApplySpeedBoost(player));
|
||
|
}
|
||
|
|
||
|
// Optionally destroy the power-up after pickup
|
||
|
Destroy(gameObject);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
private IEnumerator ApplySpeedBoost(ChasePlayerController player)
|
||
|
{
|
||
|
float originalSpeed = player.moveSpeed;
|
||
|
player.moveSpeed -= speedBoostAmount;
|
||
|
|
||
|
// Optional: trigger visual/audio effect here
|
||
|
Debug.Log("Speed Boost Activated!");
|
||
|
|
||
|
yield return new WaitForSeconds(duration);
|
||
|
|
||
|
player.moveSpeed = originalSpeed;
|
||
|
Debug.Log("Speed Boost Ended");
|
||
|
}
|
||
|
}
|