Files
BABA_YAGA/Assets/Scripts/AI NPC/LaserProjectile.cs

36 lines
719 B
C#
Raw Normal View History

2026-06-03 13:42:09 +07:00
using UnityEngine;
2026-06-04 23:01:39 +07:00
using Hallucinate.Audio;
2026-06-03 13:42:09 +07:00
public class LaserProjectile : MonoBehaviour
{
public float speed = 5f;
public float lifeTime = 5f;
2026-06-04 23:01:39 +07:00
[Header("Audio")]
public string hitSound = "Laser_Hit";
2026-06-03 13:42:09 +07:00
private void Start()
{
Destroy(gameObject, lifeTime);
}
private void Update()
{
transform.position +=
transform.forward *
speed *
Time.deltaTime;
}
private void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Player"))
{
Debug.Log("Player Hit");
2026-06-04 23:01:39 +07:00
AudioManager.Instance?.Play(hitSound, position: transform.position);
2026-06-03 13:42:09 +07:00
Destroy(gameObject);
}
}
}