adding range onto 2d raycast
Hi how do i add range onto a 2d raycast?
RaycastHit2D hit = Physics2D.Raycast(BackwardPos.position, -Vector2.up);
Debug.DrawLine (transform.position, hit.point, Color.red);
if(hit.transform.tag == "Player") {
hitobj = hit.transform.gameObject;
i have a problem where i implement the range but it doesn't work i dont know why here is my problem http://answers.unity3d.com/questions/1263540/racasthit2d-range-not-working.html
Answer by alok-kr-029 · Mar 09, 2015 at 07:54 AM
RaycastHit2D hit=Physics2D.Raycast(BackwardPos.position, -Vector2.up,1f);
where 1f is the range of the ray ,you cannot specify the range of the Debug.ray
Answer by Rude_Squash · Mar 06, 2015 at 09:06 PM
It is the third parameter of Physics2D.Raycast.
http://docs.unity3d.com/ScriptReference/Physics2D.Raycast.html
Your answer
Follow this Question
Related Questions
Making a portal inspired game - Need help! 0 Answers
Plane is blocked all Raycast 0 Answers
RayCast not working , why ??? 0 Answers
How can i get the height of an object 2 Answers
I can't get Physic.Raycast to work,My Physics.Raycast don't work 0 Answers