NPC: Version 1.0.0
This commit is contained in:
30
Assets/Scripts/AI NPC/LaserProjectile.cs
Normal file
30
Assets/Scripts/AI NPC/LaserProjectile.cs
Normal file
@@ -0,0 +1,30 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user