generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Reflecting Laser!

Previous Thread :: Next Thread 
LilMcManiac is not online. LilMcManiac
Joined: 31 Oct 2011
Total Posts: 2812
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
extremeninjamaster is not online. extremeninjamaster
Joined: 25 Feb 2012
Total Posts: 2570
09 Sep 2015 04:33 PM
Cool
Report Abuse
NovusTheory is not online. NovusTheory
Joined: 14 Oct 2009
Total Posts: 4532
09 Sep 2015 04:34 PM
Dislike your use of a while loop
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
09 Sep 2015 04:38 PM
http://www.roblox.com/games/127140614/Laser-Test
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
morashsPeasant is not online. morashsPeasant
Joined: 06 Jan 2011
Total Posts: 4944
09 Sep 2015 04:42 PM
Didn't realize OP was ur friend :P
Report Abuse
morash is not online. 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
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image