Skip to content
Snippets Groups Projects
Commit 983b66a9 authored by Nicholas R.P's avatar Nicholas R.P
Browse files

fix bug cannot game over or shoot

parent dda13043
No related branches found
No related tags found
No related merge requests found
...@@ -14,7 +14,8 @@ public class DestroyByContact : MonoBehaviour ...@@ -14,7 +14,8 @@ public class DestroyByContact : MonoBehaviour
if (gameController == null) if (gameController == null)
{ {
Debug.Log("Game Controller script not found"); Debug.Log("Game Controller script not found");
} else }
if (gameControllerObject != null)
{ {
gameController = gameControllerObject.GetComponent<GameController>(); gameController = gameControllerObject.GetComponent<GameController>();
} }
...@@ -26,12 +27,15 @@ public class DestroyByContact : MonoBehaviour ...@@ -26,12 +27,15 @@ public class DestroyByContact : MonoBehaviour
{ {
return; return;
} }
Instantiate(explosion, transform.position, transform.rotation); Instantiate(explosion, transform.position, transform.rotation);
if (other.CompareTag("Player")) if (other.CompareTag("Player"))
{ {
Instantiate(playerExplosion, other.transform.position, other.transform.rotation); Instantiate(playerExplosion, other.transform.position, other.transform.rotation);
gameController.GameOver(); gameController.GameOver();
} }
gameController.AddScore(scoreValue); gameController.AddScore(scoreValue);
Destroy(other.gameObject); Destroy(other.gameObject);
Destroy(gameObject); Destroy(gameObject);
......
...@@ -85,6 +85,6 @@ public class GameController : MonoBehaviour ...@@ -85,6 +85,6 @@ public class GameController : MonoBehaviour
public void ToggleGameOver(bool show) public void ToggleGameOver(bool show)
{ {
gameOver = show; gameOver = show;
gameOverText.text = gameOver ? "Game Over :(" : ""; gameOverText.text = gameOver ? "Game Over" : "";
} }
} }
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment