Other uses for Raycast?

Is this what I would use if I wanted 'open' text to appear when a player was close to and looking at a container? Or is there a more commonly used choice for that, something like a mouse over if you were working in 2d?

  • Jonathan Gonzalez(jgonzalez) replied

    Raycasts have a ton of uses. They just detect colliders, but you can use that information for a variety of purposes. Like you mentioned you could have a text element appear when you are looking at a specific object. Other ways of using them are to detect if you have direct line of sight to an object. For instance in an explosion I may want to use a raycast to detect what objects have direct line of sight to the explosion impact, if so we can apply damage. Anything not detected by a collider will not be damaged. 

    It's also use for point and click type mechanics. I'm actually working on an updated version of this course called the "Game Programming Bootcamp" and will contain a few new examples of raycasts being used.