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 » Scripting Helpers
Home Search
 

Re: raycasting help

Previous Thread :: Next Thread 
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
19 Jul 2011 10:43 PM
this script is a mapping sort of thing, and it has no output. what it is supposed to do: create effectively a web between parts, and then a line that connects the first dot to the target dot. it only makes a dot (part) at the center of the baseplate. oh, and there are the correct amount of ends, i just posted the broken bit.


function checkavailablepaths(main, pos, obj, target)
local obj={}
for i, v in pairs(main)do
if v~=pos then
part=Instance.new("Part",workspace)
part.formFactor=Enum.FormFactor.Custom
part.Size=Vector3.new(.2,.2,.2)
part.Anchored=true
part.CanCollide=false
part.Transparency=1
part.Position=Vector3.new(v.x,script.Parent.Torso.Position.y,v.z)
local ray2 = Ray.new(pos,(v-pos).unit*500)
s1,p1=game.Workspace:FindPartOnRay(ray2)
if s1~=nil and s1==part then
table.insert(obj, v)
table.insert(path, part)
else
part:remove()
end
end
end
for i, v in pairs(obj)do
local ray2 = Ray.new(v,(target.CFrame.p-v).unit*500)
s1,p1=game.Workspace:FindPartOnRay(ray2)
if s1~=nil and s1.Parent==target.Parent then
point=v
return point
else
point=nil
end
end
return obj, path
end

while true do
wait()



local target = findNearestTorso(script.Parent.Torso.Position)
if target ~= nil and script.Parent.Following.Value==true then
local ray = Ray.new(script.Parent.Torso.Position,(target.Position-script.Parent.Torso.Position).unit*500)

s,p=game.Workspace:FindPartOnRay(ray, script.Parent)
--print(s,p)
if s~=nil and s.Parent~=target.Parent and s.Anchored==true then
path={}
local tabl=worldcoords
local new = script.Parent.Torso.CFrame.p
local ps0={}
checkavailablepaths(tabl, new, ps0, target)
tabl=obj
if point~=nil then
else
repeat wait()
for i,v in pairs(ps0)do
checkavailablepaths(tabl, v, ps0, target)
local tabl=obj
end
until point~=nil

print(point)


end
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
19 Jul 2011 11:01 PM
tl;dr? too bad. main issue(s): with the function and the calling of the function.

function checkavailablepaths(main, pos, obj, target)
local obj={}
for i, v in pairs(main)do
if v~=pos then
part=Instance.new("Part",workspace)
part.formFactor=Enum.FormFactor.Custom
part.Size=Vector3.new(.2,.2,.2)
part.Anchored=true
part.CanCollide=false
part.Transparency=1
part.Position=Vector3.new(v.x,script.Parent.Torso.Position.y,v.z)
local ray2 = Ray.new(pos,(v-pos).unit*500)
s1,p1=game.Workspace:FindPartOnRay(ray2)
if s1~=nil and s1==part then
table.insert(obj, v)
table.insert(path, part)
else
part:remove()
end
end
end
for i, v in pairs(obj)do
local ray2 = Ray.new(v,(target.CFrame.p-v).unit*500)
s1,p1=game.Workspace:FindPartOnRay(ray2)
if s1~=nil and s1.Parent==target.Parent then
point=v
return point
else
point=nil
end
end
return obj, path
end

path={}
local tabl=worldcoords
local new = script.Parent.Torso.CFrame.p
local ps0={}
checkavailablepaths(tabl, new, ps0, target)
tabl=obj
if point~=nil then
else
repeat wait()
for i,v in pairs(ps0)do
checkavailablepaths(tabl, v, ps0, target)
local tabl=obj
end
until point~=nil
print(point)
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
19 Jul 2011 11:34 PM
bump.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
20 Jul 2011 12:10 AM
Output much?
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
20 Jul 2011 12:30 PM
no output.
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
20 Jul 2011 02:51 PM
bump.
Report Abuse
TheNewScripter is not online. TheNewScripter
Joined: 02 Mar 2010
Total Posts: 2432
20 Jul 2011 02:53 PM
You should look at oysi's raycast function. Simple and easy to use
Report Abuse
alexmach1 is not online. alexmach1
Joined: 02 May 2008
Total Posts: 1977
20 Jul 2011 03:17 PM
i know how to raycast -_- in the script, i have a series of coordinates in a table called worldcoords and each worldcoord gets a part applied to it and raycasts to eachother, and sees which worldcoord can see eachother until one can connect a series of coords with the target and the main, creating a web between the 2.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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