Raycast going further than told.

Apoligies if this is something simple, im fairly new.

I have a raycast set to go between point A and point B… however upon testing i can see that it is detecting things much further than point B, by roughly an extra 50% distance… it also detects things behind point A, and above/below these two points as well…

Forgive me if this is something simple, i was just under the impression that the raycast should stay strictly between point A and B ?

I have a line renderer set between the same points and it works perfectly further adding to my confusion with the raycast.

Thanks in advance :slight_smile:

It should if configured correctly so maybe you’re not passing the correct things to the method? A raycast requires an origin, direction and a distance.

If you want to test a line-segment from point A to B you’d be better off using Physics.Linecast or Physics2D.Linecast.

1 Like

Yeah ive just recently realised the fault is my own, as usual haha… i had point B set as a direction not am end point… i will use linecasts instead, thanks buddy :slight_smile:

Yup! Changed it to a linecast and baddabing baddaboom… works perfectly now.

1 Like