36 lines
719 B
C#
36 lines
719 B
C#
using UnityEngine;
|
|
using Hallucinate.Audio;
|
|
|
|
public class LaserProjectile : MonoBehaviour
|
|
{
|
|
public float speed = 5f;
|
|
public float lifeTime = 5f;
|
|
|
|
[Header("Audio")]
|
|
public string hitSound = "Laser_Hit";
|
|
|
|
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");
|
|
|
|
AudioManager.Instance?.Play(hitSound, position: transform.position);
|
|
|
|
Destroy(gameObject);
|
|
}
|
|
}
|
|
} |