I know this has been asked probably many times before. I’m just learning, and having trouble associating the answers to my problem.
Creating block breaker. The 3 scripts i need help interacting with are ‘LevelManager’ ‘Brick’ and ‘Losecolider’. In my bricks script I have a score. I can access this score anywhere, and it works. YAY. In my losecolider I have lives. My ball hits the colider it loses lives and displays on screen perfectly. My levelmanager handles the levels and when level 1 is completed it sends me to a WIN level 1 screen. I want to be able to add 'if lives = 5 +100 on score. I’m not sure how to access them between scripts though, and change the variable. And would i do this on the level manager? Sorry for this ramble and I appreciate any help in advance!
BRICK SCORE SECTION
if (isBreakable) {
score = score + 10;
print (score);
HandleHits();
LOSECOLIDER LIVES SECTION
void OnTriggerEnter2D (Collider2D trigger) {
lives --;
text.text = ("LIVES ") + lives.ToString();
Ball.hasStarted = false;
if (lives <= 0) {
lives = 5;
Brick.score = 0;
levelManager = GameObject.FindObjectOfType<LevelManager>();
levelManager.LoadLevel("Lose Screen");
}
LEVEL MANAGER SCRIPT (WHAT I THINK SHOULD HAVE THE ANSWER)
public void BrickDestoyed() {
if (Brick.breakableCount <= 0) {
//THIS IS WHERE I THINK IT SHOULD GO???BUT NOT SURE HOW???
// if (LoseCollider.lives = 5);
// Brick.score = Brick.score + 1000;
LoadNextLevel();
Ball.hasStarted = false;
}