30 lines
547 B
C#
30 lines
547 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
public class LaserProjectile : MonoBehaviour
|
||
|
|
{
|
||
|
|
public float speed = 5f;
|
||
|
|
public float lifeTime = 5f;
|
||
|
|
|
||
|
|
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");
|
||
|
|
|
||
|
|
Destroy(gameObject);
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|