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;
}
↧