To fellow ex-Director Developers - Raycasting

Hi guys,

As the topic says, I’m having problems with generic raycasting. I’d like to keep it as simple (though terrible) as it once was in Director - get an object’s transform, draw a line in a direction, hit something.

I’m still confused in using the proper type of raycast as the documentation shows gazillions of methods, with Physics.Raycast being the choice of many. However, I can’t seem to make this work and I’m allergic to using physics engines…

Having said that, can anyone explain/point to me a tutorial/explanation on how raycast is set up in a Unity scene? Do I need to add certain components to objects?

Scripting is no problem just setting it up.

Thanks.

Hello,

you have to make sure that your objects have colliders, with that way your ray will know what has touched.

have you checked this:

hope it helps :slight_smile:

Thanks for the quick reply naruse!

I did see that manual entry, thanks though.

When you say collider, could that be any type of collider?

yes, any type, as the ray cast “touches” it :smile:

Thanks! Finally got it working (added a collider and it still wasn’t working, checked scripts again, idiot me put the origin below the collider while the ray was shooting down!).

Thanks naruse!

No problem :wink:

Great thing you solved it :wink: !!!