(This video is not from the Pixelnest Studio guys, but it’s based on their tutorial, thus the name.)
After creating the tutorial to make random enemies for the Pixelnest-based videos I decided to keep going and add a way to finish the level instead of just flying to the right forever.
Following is a video showing the way I came up with to do that:
The Scene Finish Line (8:16)
Here’s the HitFinishLine script so you don’t have to try and copy the code from the video.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
using UnityEngine; using System.Collections; public class HitFinishLine : MonoBehaviour { private GameObject hitObj; void OnTriggerEnter2D (Collider2D collider) { hitObj = collider.gameObject; if (hitObj.tag == "Player") { transform.parent.gameObject.AddComponent<GameOverScript>(); } } } |