Issues with raycasting

Hi, so I’m making a bowling game, and for my bowling lane I’ve created an oil pattern. This oil pattern contains parts named differently, so when ever a ray is cast underneath the bowling ball, it detects which oil part the ball is on, and it’ll then set the friction of one core part that the ball is traveling on (The lane surface. I’ve found that having multiple collidable parts with physical properties turned on did not work out at all, so I’m just using one part and I adjust the physical properties of that single part depending on what oil part the ball is currently on top of, hence why I’m using raycasting.)

With all that being said, I just noticed that sometimes it actually skips over a part that the ball traveled on, and it never updated the friction of the lane to match up with it. I assume this is because I threw the ball too fast.

I hope that makes sense, and I’m not really sure how to try to go about making this more reliable, I do like the system that I’m using as far as changing the physical properties of a single part, but it seems like raycasting is becoming unreliable for this… any suggestions appreciated, thanks!

1 Like

Well luckily there was nothing wrong with how I was using Raycasting, but rather the ray I was creating had incorrect direction.

So the issue was that I used CFrame for the direction, rather than a Vector3. And this makes perfect sense, because as the ball continues to roll, depending on it’s speed, the ray might not be cast underneath the ball in the time frame of the ball rolling over that part of the oil pattern, as the direction of the ray varied on the ball’s current orientation.

So I changed that to a Vector3, and I’m seeing much more consistent results.

:slight_smile:

1 Like