Home > other >  Help raycast irradiation how to set the order
Help raycast irradiation how to set the order

Time:09-22

There is a unit or a cell in a geographic location, is the collision body

How to set up the hierarchy to raycast must first according to the unit; And when the location is not the unit can be found in the cell

CodePudding user response:

I also encountered this problem, but because demand is not the same as you, I am directly in Physics. RaycastAll returns all the collision body, then traverse the judgement of the collision body tag to solve of,

Reference methods:
The function Update () {
Var hits: RaycastHit [];
Hits=Physics. RaycastAll (transform. The position, the transform. Forward, 100.0);

//Change the material of all hit colliders
//to use a transparent Shader
//change all encounter collisions, material, use transparent shader
for (var i=0; i Var hit: RaycastHit=hits [I];
Var the renderer=hit. Starts. The renderer;
If (the renderer) {
The renderer. Material. Shader=shader. Find (" Transparent/Diffuse ");
The renderer. Material. Color. A=0.3;
}
}
}

CodePudding user response:

RaycastAll () in a fill layer layer parameters, dynamic change
  • Related