i am making a ray tracing game and i dont know how i can create a ray to reflect.
Here is my code
local Cache = script.Parent:WaitForChild("Cache")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local PixelSize = 20
local ViewPortSize = Cache.AbsoluteSize
local VSX = ViewPortSize.X
local VSY = ViewPortSize.Y
function CastRay(Origin, Direction, Ray_Length)
local R = Ray.new(Origin, Direction * Ray_Length)
local Hit, Position, Normal = workspace:FindPartOnRay()
return R, Hit, Position, Normal
end
function Render()
for X = 1, VSX do
for Y = 1, VSY do
local R = Vector2.new(workspace.CurrentCamera:ScreenPointToRay(UDim2.new(0, X, 0, Y)))
local R, Hit, Position, Normal = CastRay(R.Origin, R.Direction, 500)
print(Hit)
if Hit then
local RR, HitR, PositionR, NormalR = CastRay(R.Origin, R.Direction, 500)
end
wait()
end
wait()
end
end
wait(20)
Render()
Thanks

6 comments
There's a whole community tutorial written by Crazyman on how to make ray reflection https://devforum.roblox.com/t/how-to-reflect-rays-on-hit/18143
no i want the calculation not the code i cant find out it from code
@Ariyal1234gamer wait so is this your code or are you trying to extract some sort of equation from it. Could you please be more spesific?
ok i am making a code for drawing the camera view on UI but i am working on Relfecting now and i dont know how to calculate it if u see i created a Ray Called RR(RayReflection)
@Ariyal1234gamer It depends on what types of reflection you want to achieve. If you are working with normal and or specular maps thats gonna be much different then without. You could maybe even try screen-space reflections to be less hardware intensive, if that's a goal.
no a simple reflection math i want not any specular and normal