Hi, i want to achieve a cone of sight visualization for a top down shooter, a concept picture: should behave like the cone in Nox (westwood, year 2000) i cant find how to implement this feature but its crucial to the gameplay i am aiming at. -Its mainly what a ~300° radiation angle light source would do (except the not-rendering parts of out of sight enemy ships) -all the action happens in one Z-plane, so the shadow only needs to be 2 dimensional -i would be satisfied if the not-rendering parts wont work and i would have to use a deep black shadow to achieve sight blocking is that the only way?: http://unitycoder.com/blog/2012/01/04/fake-realtime-raycast-shadows-unity3d/ likewise problem: http://forum.unity3d.com/threads/91630-How-to-Render-a-True-Cone-of-Sight ____________________________ UPDATE: Done Basics! Now thats what i expect from TopDownShooter concerning Movement and Aiming: DOWNLOAD-WebPlayer: (OUTDATED) View attachment $SpaceNox.7z Try this instead: http://marrt.elementfx.com/ W A S D: Movement SPACE: Movement Toggle between Arcade/Referential RightMB: FreeCursor+Splitscreen on Distance, Awsome, TRY IT! ScrollWheel: Zoom the camera is a bit Jumpy but who cares yet... next Step: use mgears VisibilityMesh to Hide/show enemies... ThankYou mgear , never expected to get that far
@Quickfingerz in his recent speech for #Luug, discussing Covert (a runner up in the Flash in a Flash Unity competition) did a brute-force method, by literally raycasting 90 rays over the arc (not a cone really) and joining the dots to draw a procedural poly. It's ugly but it works. Where multiple cameras were required, he had to reduce the number of rays to keep it scaling, so may not be suitable for large numbers of enemies. I believe there is a procedural poly maker on the UnifyCommunity Unity Wiki. The other option that might work for you is to place a spotlight on the character's head, and assuming you have Unity shadows on, you should achieve a similar effect. Worth keeping in mind that this is just for the actual visuals. The actual detection can just use a single normal raycast between enemy and player or vice versa to determine if they are actually visible or not.
-Sounds good, isnt that similar to this raycast approach? http://unitycoder.com/blog/2012/01/04/fake-realtime-raycast-shadows-unity3d/ -Spotlight can only have 180° as far as i have seen in the editor, i would need a 270° sphere at least... and realtime shadows are still a pro feature I also came across this page, looks promising but i cant figure out if its cheap in performance... http://www.catalinzima.com/2010/07/my-technique-for-the-shader-based-dynamic-2d-shadows/ i admit we are still within the feasability study of this game project, checking if we can implement all features using unity(free ), this is the last issue before we can start.
There must be a simpler way, when i raycast a number of rays to far away edges it results in jumpy shadowarcs if i am not using 1000 rays: http://unitycoder.com/upload/demos/mShadowRayScan1/ maybe i can reduce the problem.... only raycasting to the edges of the polygons should be enough, also i only need to cast to the edges of the visible geometry... basically i need to solve this with multiple viewing points (share field of sight with allies): http://en.wikipedia.org/wiki/Visibility_polygon but when i use round obstacles with lot of edges it will slow down big time i guess...
theres new test version, http://unitycoder.com/blog/2012/02/15/raycast-realtime-visibility-2-0/ (its much faster, as it doesnt triangulate or make uv's in every frame, like the old one..) some interesting links, Visibility Algorithm Overview http://groups.csail.mit.edu/graphics/classes/6.838/S98/meetings/m23/alglist.html Portals and Mirrors: Simple, Fast Evaluation of Potentially Visible Sets http://www.cs.virginia.edu/~luebke/publications/portals.html A simple, fast, integer-based line-of-sight algorithm http://karoshi.auic.es/index.php?topic=1085.0
wow, thanks mgear, looks good. -does the pseudopolygon always have to have a tint? i dont want to distort the colors of the underneath textures. maybe i can add a depth shader to the created mesh to mask things out - like the one i use for dynamic splitscreen... then it should work like a cutout-the-visible-area-polygon. then they would be overlapable as well... ____ yesterday i started programming until late night (appeared late in office today though). Unity is awsome, i juggled some scripts around and after 6 hours things are already moving and doing what i want . i even managed to get non rectangular viewports working. the next biggy is this algorithm... but im faithful i want to be able to share field of view with allies, its then like a multipoint visibility polygon problem, hopefully this doesnt mess up every approach man, maybe i can even add some kind of terrain destruction using voxelform2.0
tldr, but maybe you can try this approach: http://forum.unity3d.com/threads/25138-light-and-dynamic-shadows-with-meshes-for-2d-game? There is an example scene here
made a work in progress Thread: http://forum.unity3d.com/threads/124019-SpaceNox-Working-Title?p=834143#post834143
I know this wasn't about a 3d solution, but 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/1040202706982502401