LowPolys
(LowPolys)
November 10, 2019, 2:45pm
4
If you want a base, I’d suggest looking at this. You can take the information in this and theoretically apply Snell’s law to create refraction instead of just reflecting.
Reflecting rays using raycasting
Want bullets to ricochet? Lasers to bounce? Custom Pong game? Here’s a simple way to reflect a ray when it hits a surface using the surface normal returned by the Raycast method!
Formula
We will be working with this equation :
r = d - 2(d ⋅ n)n
Where r is the resultant reflection normal, d is the normal of our ray, and n is the surface normal that our ray hit (We will get n from the RaycastResult that the Raycast method returns).
Because we are doing reflec…