using System.Collections; using System.Collections.Generic; using UnityEngine; public class Projectile : MonoBehaviour { private bool collided; Vector3 oldEulerAngles; public float damage; private string element = null; 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) { Debug.LogWarning(collision.gameObject.name); GameObject obj = collision.gameObject; if (obj.tag != "IceBolt" && obj.tag != "Player" && !collided) { collided = true; if (obj.CompareTag("Slime")) { obj.GetComponent().GetHit(Mathf.RoundToInt(damage)); } Destroy(gameObject); } } 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); } } }