Unity3d enemy cone angle implementation idea, unity3d cone
In particular, we want to achieve a conical angle effect like the death of an army.
Think about it. Think of some stupid methods. If you have any good methods, please let me know.
1. Raycast Method
Transmits rays from the position of a person, and thenDebug. DrawLine
However, only rays can be drawn without cone effects.
if (Physics.Raycast(transform.position, rayDirection, out hit, ViewDistance)) { //Check the aspect if (hit.collider.name != "player") { Debug.DrawLine(transform.position, hit.point, Color.green); } } else { Debug.DrawLine(transform.position, leftRayPoint, Color.green); }
Debug. DrawLine must be implemented in the OnDrawGizmos () event
2. Spotlight Method
The simplest method is to place the Spotlight on the horizontal plane and over the ground. If you want to project something like the ground, create a new layer and set it to Spotlight culling mask to enable it to avoid unnecessary illumination.
3. Projection Method
The most cheating method is to put a conical object above the character, where the blogger is lazy, uses plane, places it in a place not visible to the camera (infinitely higher), and adds a new direction of light, in the vertical direction, the layer settings are the same as above. To change the shadow color, write the shader by yourself ..
You can tell me a better way.
----- By wolf96 http://blog.csdn.net/wolf96
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.