2022-03-24 16:02:34 +00:00
|
|
|
using System.Collections;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
public class Projectile : MonoBehaviour
|
|
|
|
{
|
|
|
|
private bool collided;
|
2022-04-07 14:03:21 +00:00
|
|
|
Vector3 oldEulerAngles;
|
|
|
|
|
|
|
|
private void Start()
|
|
|
|
{
|
|
|
|
// Will always be destroyed after 10 seconds.
|
|
|
|
Destroy(gameObject, 10);
|
|
|
|
|
2022-04-18 08:29:26 +00:00
|
|
|
//oldEulerAngles = transform.rotation.eulerAngles;
|
2022-04-07 14:03:21 +00:00
|
|
|
}
|
|
|
|
private void Update()
|
|
|
|
{
|
2022-04-18 08:29:26 +00:00
|
|
|
/*if (oldEulerAngles != transform.rotation.eulerAngles)
|
2022-04-07 14:03:21 +00:00
|
|
|
{
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
2022-04-18 08:29:26 +00:00
|
|
|
*/
|
2022-04-07 14:03:21 +00:00
|
|
|
}
|
|
|
|
|
2022-04-18 08:29:26 +00:00
|
|
|
private void OnCollisionEnter(Collision collision)
|
2022-03-24 16:02:34 +00:00
|
|
|
{
|
2022-04-18 08:29:26 +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;
|
2022-04-18 08:29:26 +00:00
|
|
|
if (collision.gameObject.name == "Dummy") Destroy(collision.gameObject); //REPLACE WITH ENEMY TAG CHECK
|
2022-03-24 16:02:34 +00:00
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
2022-04-18 08:29:26 +00:00
|
|
|
|
2022-03-24 16:02:34 +00:00
|
|
|
}
|
2022-04-18 08:29:26 +00:00
|
|
|
private void OnTriggerEnter(Collider other)
|
2022-04-07 14:03:21 +00:00
|
|
|
{
|
2022-04-18 08:29:26 +00:00
|
|
|
Debug.LogWarning(other.gameObject.name);
|
2022-04-07 14:03:21 +00:00
|
|
|
if (other.gameObject.tag != "IceBolt" && other.gameObject.tag != "Player" && !collided)
|
|
|
|
{
|
|
|
|
collided = true;
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
2022-04-18 08:29:26 +00:00
|
|
|
else if (other.gameObject.name == "Dummy")
|
|
|
|
{
|
|
|
|
Destroy(other.gameObject);
|
|
|
|
Destroy(gameObject);
|
|
|
|
}
|
2022-04-07 14:03:21 +00:00
|
|
|
}
|
2022-03-24 16:02:34 +00:00
|
|
|
}
|