Unknown Error

I have a little script:

var Mesh_Render :MeshRenderer;
Mesh_Render = GetComponent.();
var rango :boolean = false;

function Start () {
Mesh_Render.enabled = false;
}

function OnTriggerEnter(Coll : Collider) {
rango = true;

}

function OnTriggerExit(Coll : Collider) {
rango = false;

}

function Update(){
if(rango == true) {
Mesh_Render.enabled = true;
}

if(rango == false) {
Mesh_Render.enabled = false;
}

}

When I put this in the enemy the mesh render is flashing randomly.
Help!!
I use unity 5

My guess (and it’s just a guess) is that you’re enemy is flashing because it’s coming into contact with other colliders… The floor? Any other objects? You’re not specifying WHAT should make it trigger on and off, other than another collider (if it has more than one collider, it may even be triggering itself). Try something like this…

var Mesh_Render : MeshRenderer;
var rango : boolean = false;

function Start ()
{
    Mesh_Render = GetComponent.<MeshRenderer>();
    Mesh_Render.enabled = false;
}

function OnTriggerEnter(Coll : Collider)
{
    if (Coll.gameObject.name == "Player")
    {
        rango = true;
    }
}

function OnTriggerExit(Coll : Collider)
{
    if (Coll.gameObject.name == "Player")
    {
        rango = false;
    }
}

function Update()
{
    if(rango == true)
    {
        Mesh_Render.enabled = true;
    }
    if(rango == false)
    {
        Mesh_Render.enabled = false;
    }
}

In this example, of course, the object is looking for a colliding object named Player, so if the object you’re looking to compare collisions with is named something else, you’ll want to change that. You could also have it check for various names, tags, layers, depending on just what you’re trying to achieve.