My ray is inverted?

So I’m making a function inside an AI that’s checking for obstruction between position X and position Y
But the outcomes I got on the function were a bit odd, so I made the ray physical.
This is what I saw: https://gyazo.com/76807fdba951d8cfd1945e6af2fd5e0f
It looks like my ray is inverted or something?
Here’s my script: https://gyazo.com/ccffe6eade71c0be3abed418d2ec9062

2 Likes

The second argument of the Ray constructor is a directional vector, not a destination vector. It’s not that your ray is inverted necessarily, it’s that it isn’t correctly cast. If you really want to use it like a destination vector, then you should be getting a unit ray from a vector (don’t know what that’d be in your implementation) and then extending it out.

2 Likes

To counteract that, you should add 180 degrees to the orientation.

This one I’m not really sure about:

instead of using -mag/2, just use mag/2 on line 15

1 Like

That doesn’t work either, and has nothing really to do with the actual non physical ray.

So, how do you find the direction?

Nevermind, just found out, thanks for the help though.

I am not sure, but (end-start).Unit