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 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