I made spikes model and imported in unity and added Mesh Collider( convex + Is trigger), and made script if the player gets in collision with the spikes the level gets restarted. But i get this error nullreferenceexception object reference not set to an instance of an object.
Here is my code:
#pragma strict
var gameMaster : GameMaster;
function OnTriggerEnter (colInfo : Collider)
{
if(gameMaster.isRestarting == false)
{
Debug.Log("Test");
if(colInfo.tag == "Player")
{
var destructible : Destructible = colInfo.GetComponent("Destructible") as Destructible;
destructible.Destruct();
}
gameMaster.RestartLevel();
}
}
how can i fix this?