Source Code for ship.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ship : MonoBehaviour {
public GameObject explosion;
private void OnTriggerEnter2D(Collider2D other){
Debug.Log("hit detected");
GameObject e = Instantiate(explosion) as GameObject;
e.transform.position = transform.position;
Destroy(other.gameObject);
this.gameObject.SetActive(false);
}
}
Resources
1. Mobile Joystick Tutorial
2. Keeping Objects in Bounds
3. Spawning Obstacles Tutorial
Click here to download the explosion sprite sheet used in this video.