Transparrent Trees
Hi All, I am making a top down 3d Shooter and i would like to make it when a player gets near a Tree in the terrain it goes transparent, I have this working for trees outside the terrain but not apart of the terrain
What Im using
public GameObject primaryTerrain;
public TerrainData primaryTData;
private GameObject instanceTerrain;
private TerrainData instanceTData;
RaycastHit[] hits;
hits = Physics.RaycastAll(transform.position, transform.forward, 100.0F);
for (int i = 0; i < hits.Length; i++)
{
RaycastHit hit = hits[i];
Renderer rend = hit.transform.GetComponent<Renderer>();
if (rend)
{
// Change the material of all hit colliders
// to use a transparent shader.
rend.material.shader = Shader.Find("Transparent/Diffuse");
Color tempColor = rend.material.color;
tempColor.a = 0.3F;
rend.material.color = tempColor;
}
}
Comment
Your answer
Follow this Question
Related Questions
Following through terrain with FPSController 0 Answers
How to create trees with working mesh colliders ? 0 Answers
OnTriggerEnter does not work on placed terrain trees 0 Answers
Trees like in City Skylines 0 Answers