Answers for "Firing rays in a cone shape from the player"
http://answers.unity.com/questions/986053/firing-rays-in-a-cone-shape-from-the-player.html
The latest answers for the question "Firing rays in a cone shape from the player"Answer by okletshavesomefun
http://answers.unity.com/answers/1553460/view.html
I saw several people looking for a ConeCast, so I made one. It's an extension method to use as Physics.ConeCastAll:
https://twitter.com/WalterEllisFun/status/1040202706982502401Sat, 15 Sep 2018 10:37:49 GMTokletshavesomefunAnswer by crare
http://answers.unity.com/answers/1303013/view.html
You could have cone shaped collider and check if it's not behind something with raycast towards target while onCollision with the collider. https://docs.unity3d.com/ScriptReference/Collider.OnCollisionStay.htmlTue, 24 Jan 2017 07:39:45 GMTcrareAnswer by Tolufoyeh
http://answers.unity.com/answers/1225325/view.html
Here's Unity's own tutor's code https://unity3d.com/learn/tutorials/projects/stealth-tutorial-4x-only/enemy-sightFri, 05 Aug 2016 10:53:29 GMTTolufoyehAnswer by Hellium
http://answers.unity.com/answers/986129/view.html
If you want to trace a cone, I would suggest to "construct" your cone as follow :
You know the main axis of your cone, thanks to the transform.forward of your spawn point.
Then, you also have two vectors belonging to the base of your cone : transform.up and transform.right.
![alt text][1]
You have the radius of your cone (I guess) and your step angles (in radians). Thus, you can draw a circle like the Unit Circle Trigonometry : transform.right * cos(angle) * r + transform.up * sin(angle) * r. You now have a set of points, you have the apex of your cone, you can have a vector ! This vector is the direction + length of your ray.
EDIT : If you want your radius, you will have to use the following formula :
You know that *tan α = opposite / adjacent* where α is you angle. You want *opposite* (you already know adjacent, which is the height of your cone).
Thus, *opposite = tan α x adjacent*
![alt text][2]
![alt text][3]
Though, I would recommend to use a solid mesh as a trigger to detect a collision from your bullet. (Just make it on a 3D software like blender, it takes 2 minutes, export it in fbx, remove mesh renderer, add mesh collider)
[1]: /storage/temp/48169-cone.png
[2]: /storage/temp/48170-triangle.png
[3]: http://www.snow.edu/jonathanb/images/unitcircle1.gifSat, 13 Jun 2015 19:34:27 GMTHellium