|
| 09 Sep 2015 04:18 PM |
I finally figured out how to make a reflecting laser!
Insert a brick named Emitter, and Ignore in the workspace.
function Trace_Ray(Ray_Pos) local Part = Instance.new("Part") Part.Name = "Beam" Part.Transparency = .25 Part.Reflectance = .25 Part.FormFactor = "Custom" Part.Anchored = true Part.BrickColor = BrickColor.Red() Part.Size = Vector3.new(.2, .2, (Current - Ray_Pos).Magnitude) Part.CFrame = CFrame.new(Current + (Ray_Pos - Current) / 2, Ray_Pos) Part.Parent = workspace.Ignore end function Not_Zero(Value) local Up = math.ceil(Value + .1) local Down = math.floor(Value - .1) if Up ~= 0 and Up ~= -0 then return Up elseif Down ~= 0 and Down ~= -0 then return Down end end Current = Vector3.new(0, 3, 0) Heading = Vector3.new(0, 0, -1) Ray_Part, Ray_Pos = workspace:FindPartOnRay(Ray.new(Current, Heading * 900), workspace.Ignore) if Ray_Part then Trace_Ray(Ray_Pos) Current = Ray_Pos Angle = Ray_Part.CFrame.lookVector local R_X, R_Z = (Angle.X + Heading.X) / 2, (Angle.Z + Heading.Z) / 2 Heading = Vector3.new(R_X * -Heading.Z, 0, R_Z * -Heading.X).unit end repeat Ray_Part, Ray_Pos = workspace:FindPartOnRay(Ray.new(Current, Heading * 250), workspace.Ignore) if Ray_Part then Trace_Ray(Ray_Pos) Current = Ray_Pos Angle = Ray_Part.CFrame.lookVector local R_X, R_Z = (Angle.X + Heading.X) / 2, (Angle.Z + Heading.Z) / 2 Heading = Vector3.new(R_X * -Heading.Z, 0, R_Z * -Heading.X).unit end until not Ray_Part or Ray_Part.Name == "Stop" Trace_Ray(Ray_Pos)
while wait() do Current = workspace.Emitter.Position Heading = workspace.Emitter.CFrame.lookVector for _,Beam in ipairs(workspace.Ignore:GetChildren())do Ray_Part, Ray_Pos = workspace:FindPartOnRay(Ray.new(Current, Heading * 900), workspace.Ignore) if Ray_Part then Beam.Size = Vector3.new(.2, .2, (Current - Ray_Pos).Magnitude) Beam.CFrame = CFrame.new(Current + (Ray_Pos - Current) / 2, Ray_Pos) Current = Ray_Pos - Heading * .1 Angle = Ray_Part.CFrame.lookVector local R_X, R_Z = (Angle.X + Heading.X) / 2, (Angle.Z + Heading.Z) / 2 Heading = Vector3.new(R_X * -Heading.Z, 0, R_Z * -Heading.X).unit else Beam:Destroy() end end Ray_Part, Ray_Pos = workspace:FindPartOnRay(Ray.new(Current, Heading * 900), workspace.Ignore) if Ray_Part and #workspace.Ignore:GetChildren() < 15 then Trace_Ray(Ray_Pos) end end |
|
|
| Report Abuse |
|
| |
|
| 09 Sep 2015 04:34 PM |
| Dislike your use of a while loop |
|
|
| Report Abuse |
|
|
| 09 Sep 2015 04:38 PM |
| http://www.roblox.com/games/127140614/Laser-Test |
|
|
| Report Abuse |
|
|
| 09 Sep 2015 04:40 PM |
| That moment when you've been on the forum for over a year and you finally realize that your friend on the forum is the one who made your favorite tech demo |
|
|
| Report Abuse |
|
|
| 09 Sep 2015 04:42 PM |
| Didn't realize OP was ur friend :P |
|
|
| Report Abuse |
|
morash
|
  |
| Joined: 22 May 2010 |
| Total Posts: 5834 |
|
|
| 09 Sep 2015 04:49 PM |
| I believe there was a blog post about reflecting lasers. |
|
|
| Report Abuse |
|
|
| 09 Sep 2015 05:23 PM |
I was referring to buildersteven4, who made the demo at the link I gave. I've known about that place of his since long before I came to the forums. Then I was here for over a year, and still didn't know he made it. |
|
|
| Report Abuse |
|