How to account for size of projectile while reflective raycasting

So this tutorial:

has been really helpful to me, as before I was doing a much more complicated procedure to accomplish this where I got the direction vector, got the hit position, and then used the hit position as the reflection axis. Anyways, long story short, it took about 5-7 lines of code to accomplish (if I recall correctly) just to get the reflected vector. However, recently I’ve begun working on a game version of the ‘disc wars’ from Tron: Legacy. One of my problems however is that I do not know how to handle the disc clipping through the wall while moving through the air.

With regular bullets, the side of the bullet clipping through a wall is fine, as the bullets are usually skinny and it’s only noticeable when you are looking for it specifically. However, when using a cylindrical disc as a projectile the effect becomes much more noticeable.

This is where the disc should hit the wall and thus reflect off of it.
Screen Shot 2021-03-23 at 4.55.04 PM

However, because I’m using Raycasting, all I’m doing is detecting when the ray hits the wall, not the projectile. This means that the end result is something like this:
Screen Shot 2021-03-23 at 4.56.48 PM

As you can see, the disc is clearly clipping through the wall. Some players may not notice this but the majority will most likely see it at some point.

Summarized, what I want is this:
What I want is a way to detect at what point the disc hits the wall in a non head-on collision (as in the first picture) and then calculate the reflected ray off of that point.

I’d just make the disk offset back the radius of the disk from where its casting

On the rebound just raycast from 1 diameter away from the wall along the new reflected vector so it moves back 1 radius and rests nicely on the wall

(just a side comment you might want to do a separate raycast from the distance touching the wall to the 1 diameter away on the rebound in case someones touching the wall)
image

1 Like

After testing this out this only works for angles that aren’t nearly parallel with the wall. Even then I still wouldn’t know how to re-calculate the angle of reflection from that point.

P.S. - As a side note, how do you create example pictures like you did? I wanted to do something like that in my original post but didn’t know how to create them.

Thanks for the help, but I’ve figured it out on my own. The solution was to replace the short raycast I was making with a really long one to detect when I might hit a wall. Then if it got a hit i could check the distance and the part to get the nearest position on the surface normal. Then I’d get the result of Vector3:Cross and enter in into my equation.