Added project
This commit is contained in:
31
Project1/Assets/Scripts/DeathTrigger.cs
Normal file
31
Project1/Assets/Scripts/DeathTrigger.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
/*
|
||||
Author: Alexandrov Alexander Alexandrovich
|
||||
Date: 25/10/2019
|
||||
|
||||
Script that implement death of player character
|
||||
*/
|
||||
public class DeathTrigger : MonoBehaviour {
|
||||
|
||||
private GameController gameController;
|
||||
|
||||
void Start() {
|
||||
GameObject gameControllerObject = GameObject.FindGameObjectWithTag("game_controller");
|
||||
if (gameControllerObject != null) {
|
||||
gameController = gameControllerObject.GetComponent<GameController>();
|
||||
} else {
|
||||
Debug.Log("Cannot find 'GameController' script!");
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerEnter2D(Collider2D other) {
|
||||
if (other.gameObject.CompareTag("Player")) {
|
||||
Destroy(other.gameObject);
|
||||
gameController.GameOver();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user