Skip to content
Snippets Groups Projects
Commit 73fceaa0 authored by Miika Toivanen's avatar Miika Toivanen
Browse files

MissileScript

parent 0418c6be
Branches
Tags
No related merge requests found
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);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment