Heroes_of_Hiis/Assets/Project Files/Scripts/JonasB/Projectile.cs

42 lines
994 B
C#
Raw Normal View History

2022-03-24 16:02:34 +00:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Projectile : MonoBehaviour
{
private bool collided;
Vector3 oldEulerAngles;
private void Start()
{
// Will always be destroyed after 10 seconds.
Destroy(gameObject, 10);
oldEulerAngles = transform.rotation.eulerAngles;
}
private void Update()
{
if (oldEulerAngles != transform.rotation.eulerAngles)
{
Destroy(gameObject);
}
}
2022-03-24 16:02:34 +00:00
private void onCollisionEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
}
private void onTriggerEnter(Collider other)
{
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
}
2022-03-24 16:02:34 +00:00
}