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

52 lines
1.4 KiB
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);
}
*/
}
private void OnCollisionEnter(Collision collision)
2022-03-24 16:02:34 +00:00
{
Debug.LogWarning(collision.gameObject.name);
if (collision.gameObject.tag != "IceBolt" && collision.gameObject.tag != "Player" && !collided)
2022-03-24 16:02:34 +00:00
{
collided = true;
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK
2022-03-24 16:02:34 +00:00
Destroy(gameObject);
}
2022-03-24 16:02:34 +00:00
}
private void OnTriggerEnter(Collider other)
{
Debug.LogWarning(other.gameObject.name);
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
{
collided = true;
Destroy(gameObject);
}
else if (other.gameObject.name == "Dummy")
{
Destroy(other.gameObject);
Destroy(gameObject);
}
}
2022-03-24 16:02:34 +00:00
}