#issues with raycast function
1 messages · Page 1 of 1 (latest)
I assume it moves the rat back further?
Ray
Phone autocorrect sucks
I have a secret to tell you, if the direction is going from origin to mouse.target.position it will always be nil because the target position isn’t in the ground it’s on the surface of the part or anything tldr: too accurate lmao
It’s because the ray cast isn’t intersecting with the ground if your target position is from a ray cast, using that gets unreliable (more like doesn’t work at all lol)
yes thats why i said direction*2 so it doesn't get caught in the edge case where the direction is precisely 0 units away from intersecting the mouse.hit position, so make the direction slightly longer to account. its just easier to say double it.
You gotta explain it to the s0 đź’Ż
🧑‍💻
they're probably not going to understand that, nerd 
So essentially since I'm casting a ray to a vector3 that sometimes isn't in the part I click, so I would need to increase the distance it moves so it ensures it hits something
Which would be increasing the direction distance which can be done by multiplying the direction
Is that what I was doing wrong?
Yes
try it, its only one line
I will when I'm back home

For now I will mark this thread as solved until further errors I can notice happens
its similar to the z-fighting problem, there's some floating point precision matters thrown in where sometimes it may be long enough other times not etc, not entirely guaranteed. you only need to add at least epsilon but because of floating point precision its just easier to *2 the direction. you could get away with *1.00000001 to a degree but idk i'd go with *1.1 at minimum so the epsilon is guaranteed to be big enough
I like the sounds of 1.5
Although I don't know what you mean by z-fighting
I understand the point being brought to me
Thank you for explaining this to me