[Solved] Simulate Destroy brick doesn't work

Hi
I finish Section 5 Lecture 83 and Unfortunately my ball don’t Destroy the bricks
I check my scripts and Everything is fine.
What cloud be the Problem?

thank’s A head…

Hello @Inbal_Shtraichman-Ta,

Can you post your code please, for the Brick.cs script.

using UnityEngine;
using System.Collections;

public class brick : MonoBehaviour {
public int maxHit;
private int timeHit;
private LevelManager LevelManager;
// Use this for initialization
void Start () {
timeHit = (0);
LevelManager = GameObject.FindObjectOfType();
}

void OncollisionEnter2D (Collision2D col){
	timeHit++;
	SimulateWin();
}
	
void SimulateWin(){
	LevelManager.LoadNextLevel();

}
}

Great, thanks.

C# is case sensitive, you need to capitalise the “C” in the OnCollisionEnter2D() method, at the moment, your method OncollissionEnter2D() will not be being called by anything, as such, the method SimulateWin() is not call either.


See also;

Hi Rob
Thank You Very Much - It Works!!
(Solved)

Inbal

1 Like

You are more than welcome.

If you write your own methods you can of course spell them how you wish and use whatever “case” you want, but with any Unity or C# specific ones, they must match. Something to look out for in the future. I would recommend that even with your own you follow the same naming conventions though, it will make things easier for you in the future :slight_smile:

Privacy & Terms