{"id":99,"date":"2013-04-08T17:56:04","date_gmt":"2013-04-08T17:56:04","guid":{"rendered":"http:\/\/lotecsoftware.com\/unity\/blog\/?p=99"},"modified":"2022-09-10T15:27:00","modified_gmt":"2022-09-10T13:27:00","slug":"to-raycast-or-not-to-raycast","status":"publish","type":"post","link":"http:\/\/lotecsoftware.com\/unity\/blog\/?p=99","title":{"rendered":"To RayCast or not to RayCast"},"content":{"rendered":"<p>I&#8217;ve implemented a RayCast:ing version of finding out if a UsableObject is in front of the player. This is done by casting a ray from the players position 1 meter forward. If it hits anything on the layer Usable, it knows an object is on front.<\/p>\n<p>The old version was by having a trigger collider that sensed if the player entered its area.<\/p>\n<p>Differences positive or negative?<br \/>\nRayCast: When turning around the door will not be sensed, because the player won&#8217;t &#8220;see&#8221; it.<br \/>\nOld: Opposite. While the player is in the trigger area it will be sensed.<\/p>\n<p>The Raycast method does seem a bit more natural, but it also involved casting a ray every frame. Not sure if that is cpu intensive since I do not have a profiler (no pro version).<\/p>\n<p>Try out the difference here. The left door is the new one. <a href=\"http:\/\/lotecsoftware.com\/unity\/week3_test2\/week3_test2.html\">Raycast version<\/a><\/p>\n<p>PS I just noticed something seems weird with this web version. Can&#8217;t change any settings or look up with the mouse. Will investigate later.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;ve implemented a RayCast:ing version of finding out if a UsableObject is in front of the player. This is done by casting a ray from the players position 1 meter forward. If it hits anything on the layer Usable, it knows an object is on front. The old version was by having a trigger collider [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=\/wp\/v2\/posts\/99"}],"collection":[{"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=99"}],"version-history":[{"count":3,"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=\/wp\/v2\/posts\/99\/revisions"}],"predecessor-version":[{"id":128,"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=\/wp\/v2\/posts\/99\/revisions\/128"}],"wp:attachment":[{"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=99"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=99"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/lotecsoftware.com\/unity\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=99"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}