- Home /
Help with a simple function.
I need a function that takes two points as arguments and returns true if the line segment connecting them passes through a solid object, and otherwise returns false. How would I implement this?
Comment
Answer by iggy · Jun 08, 2011 at 11:25 PM
there is already a function for that. you can use it like this:
return Physics.Linecast(point1.position, point2.position);
or read more here: http://unity3d.com/support/documentation/ScriptReference/Physics.Linecast.html
Your answer
![](https://koobas.hobune.stream/wayback/20220612101707im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How to make it so enemies only move towards the player when the player is colliding with an object 1 Answer
Need AI script that makes object follow the player (and collidors work) 1 Answer
Why is my AI not thinking the collisions fast enough? 1 Answer
Pausing/Waiting/Stopping code in a 2D Collision Function 1 Answer