#issues with raycast function

1 messages · Page 1 of 1 (latest)

young hearth
#

i keep getting nil returned back and i dont know why

#

the mouse is game.Player.LocalPlayer:GetMouse()

coral zenith
#

workspace:raycast can return nil if it doesnt hit anything

#

maybe do direction*=2

young hearth
#

Ray

#

Phone autocorrect sucks

frail verge
#

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

frail verge
coral zenith
frail verge
#

🧑‍💻

coral zenith
young hearth
#

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?

coral zenith
young hearth
#

I will when I'm back home

young hearth
#

For now I will mark this thread as solved until further errors I can notice happens

coral zenith
# young hearth So essentially since I'm casting a ray to a vector3 that sometimes isn't in the ...

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

young hearth
#

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

young hearth
#

Thank you for explaining this to me