{"id":1360,"date":"2012-10-29T01:30:18","date_gmt":"2012-10-28T22:30:18","guid":{"rendered":"http:\/\/unitycoder.com\/blog\/?p=1360"},"modified":"2018-03-13T14:28:46","modified_gmt":"2018-03-13T06:28:46","slug":"2d-raycasting-visibility-voxel-travelsal","status":"publish","type":"post","link":"https:\/\/unitycoder.com\/blog\/2012\/10\/29\/2d-raycasting-visibility-voxel-travelsal\/","title":{"rendered":"2D Raycasting Visibility &#8211; Voxel Travelsal"},"content":{"rendered":"<p><a title=\"start webplayer demo\" href=\"http:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting1\/\" target=\"_blank\" rel=\"noopener\"><img data-recalc-dims=\"1\" loading=\"lazy\" decoding=\"async\" data-attachment-id=\"1361\" data-permalink=\"https:\/\/unitycoder.com\/blog\/2012\/10\/29\/2d-raycasting-visibility-voxel-travelsal\/voxel_travelsal_2d_raycast_visibility_1\/\" data-orig-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/voxel_travelsal_2D_raycast_visibility_1.jpg?fit=680%2C486&amp;ssl=1\" data-orig-size=\"680,486\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;}\" data-image-title=\"voxel_travelsal_2D_raycast_visibility_1\" data-image-description=\"\" data-image-caption=\"\" data-large-file=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/voxel_travelsal_2D_raycast_visibility_1.jpg?fit=680%2C486&amp;ssl=1\" class=\"alignnone size-full wp-image-1361\" title=\"voxel_travelsal_2D_raycast_visibility_1\" src=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/voxel_travelsal_2D_raycast_visibility_1.jpg?resize=680%2C486\" alt=\"\" width=\"680\" height=\"486\" srcset=\"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/voxel_travelsal_2D_raycast_visibility_1.jpg?w=680&amp;ssl=1 680w, https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/voxel_travelsal_2D_raycast_visibility_1.jpg?resize=300%2C214&amp;ssl=1 300w\" sizes=\"auto, (max-width: 680px) 100vw, 680px\" \/><\/a><\/p>\n<p>Converted <a title=\"http:\/\/dev.mothteeth.com\/2011\/11\/2d-ray-casting-on-a-grid-in-as3\/\" href=\"http:\/\/dev.mothteeth.com\/2011\/11\/2d-ray-casting-on-a-grid-in-as3\/\" target=\"_blank\" rel=\"noopener\">this AS3 2D raycast<\/a> <em>(by Lee Grey)<\/em> to Unity javascript. (Image: raycast is coming from the middle, hits a wall..)<\/p>\n<p><strong>Next:<\/strong><br \/>\n<em> &#8211; Use grid array instead of reading pixels from image.. (done)<\/em><br \/>\n<em> &#8211; Try if this is faster compared to the old <a title=\"http:\/\/unitycoder.com\/blog\/2012\/02\/15\/raycast-realtime-visibility-2-0\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/02\/15\/raycast-realtime-visibility-2-0\/\" target=\"_blank\" rel=\"noopener\">Raycast visibility code<\/a> (done)<\/em><br \/>\n&#8211; And would this ever work with moving objects..?<br \/>\n&#8211; 3D version needed for <a title=\"http:\/\/unitycoder.com\/blog\/2012\/09\/30\/marching-cubes-voxel-terrain\/\" href=\"http:\/\/unitycoder.com\/blog\/2012\/09\/30\/marching-cubes-voxel-terrain\/\" target=\"_blank\" rel=\"noopener\">Voxel Terrain digging<\/a> (mesh collider is too slow)<\/p>\n<p><strong>Some results:<\/strong><br \/>\n&#8211; v2.0: 50000 rays, mainthread: ~40ms (using 2D grid map) vs. old real raycast ~68ms<\/p>\n<p><strong>Added version 2.0 webplayer:<\/strong><br \/>\n&#8211; Calculates 512 rays for visibility with voxel travelsal.<\/p>\n<p><strong>Webplayer:<\/strong><a title=\"http:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting1\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting1\/\" target=\"_blank\" rel=\"noopener\"><br \/>\nhttp:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting1\/<\/a> (v1.0)<br \/>\n<a title=\"http:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting2\/\" href=\"http:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting2\/\" target=\"_blank\" rel=\"noopener\">http:\/\/unitycoder.com\/upload\/demos\/VoxelTravelsal2DRaycasting2\/<\/a> (v2.0)<\/p>\n<p><strong>Download source:<\/strong><br \/>\n<a title=\"Download (with UnityCoder toolbar)\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=386&amp;uid=un1t3c0d5r\" target=\"_blank\" rel=\"noopener\">voxelTravelsal1.unityPackage<\/a><br \/>\n<a title=\"Download (with UnityCoder toolbar)\" href=\"http:\/\/unitycoder.com\/download\/index2.php?link=389&amp;uid=un1t3c0d5r\" target=\"_blank\" rel=\"noopener\">voxelTravelsal2.unityPackage<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Converted this AS3 2D raycast (by Lee Grey) to Unity javascript. (Image: raycast is coming from the middle, hits a wall..) Next: &#8211; Use grid array instead of reading pixels from image.. (done) &#8211; Try if this is faster compared to the old Raycast visibility [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1361,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[4,3],"tags":[65,354,317,98,172,311,353],"class_list":["post-1360","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-demos","category-unity3d","tag-2d","tag-grid","tag-ray","tag-raycast","tag-visibility","tag-voxel","tag-voxel-travelsal"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"https:\/\/i0.wp.com\/unitycoder.com\/blog\/wp-content\/uploads\/2012\/10\/voxel_travelsal_2D_raycast_visibility_1.jpg?fit=680%2C486&ssl=1","jetpack_shortlink":"https:\/\/wp.me\/p1KTaT-lW","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1360","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/comments?post=1360"}],"version-history":[{"count":16,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1360\/revisions"}],"predecessor-version":[{"id":5934,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/posts\/1360\/revisions\/5934"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media\/1361"}],"wp:attachment":[{"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/media?parent=1360"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/categories?post=1360"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unitycoder.com\/blog\/wp-json\/wp\/v2\/tags?post=1360"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}