using System.Collections; using System.Collections.Generic; using UnityEngine; public class MissileScript : MonoBehaviour { public float speed; public ParticleSystem expl; void Update() { transform.position -= new Vector3(speed, 0, 0) * Time.deltaTime; // Moves the object left if (transform.position.x - GameObject.FindGameObjectWithTag("Player").transform.position.x < -20) { Destroy(gameObject); } } private void OnCollisionEnter2D(Collision2D collision) { Instantiate(expl, transform.position, transform.rotation); Destroy(gameObject); } }