Quantcast
Channel: Questions in topic: "javascipt"
Viewing all articles
Browse latest Browse all 1875

Raycast needs to ignore GameObjects called Platforms. What is the best way to do this?

$
0
0
Here's a custom function I use to detect a Raycast hit. At the moment the Raycast function sees if it hit nothing or something. I need it to ignore GameObjects that are named "Platforms". I know I can use tags or layers, but I don't understand the full benefits from using custom tags or layers other than using them for organization. I have other Raycasts that need to detect the GameObjects named "Platforms" so I can't have all Raycasts ignore "Platforms". **TL;DR**: I need advice on getting the Raycast function to ignore "Platforms" GameObjects, thanks. JS code: function Raycast(dir : Vector3, position : Vector3) : Vector3{ var hit : RaycastHit2D = Physics2D.Raycast(position, dir, 2); if(hit.collider != null){ return hit.point; } return position + dir*100; }

Viewing all articles
Browse latest Browse all 1875

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>