[2d] hidden object gets visible in radar circle

Hey guys,

I hope the headline describes already quite good what I am looking for.
I am quite new to unity and currently I develop a little arcade shooter and there should be hidden mines, that come visible when they hit the radar section of the space ship … and they should not be seen directly at ones … they should become slowly visible when they enter the radar area … how can I archive this?

Hope for ur help …
Thx Applepie

Hi Applepie,

[1] To achieve the mines becoming visible when they enter the radar, you can simply enable or disable the SpriteRenderer(assuming you are using this, or MeshRenderer if you are using that) accordingly.

[2] For the fading, I would set a bool on the mines that changes the alpha value of the material like so;

bool isVisible;
float alpha = 0;

void Update()
{
   if(isVisible)
      FadeIn();
}

void FadeIn()
{
    Color prev = GetComponent<SpriteRenderer>.material.color;

    if(alpha < 1)
      alpha += 0.01f; //Change 0.01f to your liking

    Color col = new Vector4(prev.r, prev.g, prev.b, alpha);
    GetComponent<SpriteRenderer>().material.color = col;
}

Set isVisible to true when it enters the radar area.

Hope this helps.