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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

More raycasting help...?

Previous Thread :: Next Thread 
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:19 PM
i know every problem ive asked so far ive managed to fix with alot of trial and error... but here comes another

Heres my code so far:
for II = 1, #Isl do
local Part = Isl[II]
for I = 1, 4 do
wait()
local Angle = math.rad(((I*90)-90))
local Start = ((Part.CFrame)* (CFrame.Angles(0, Angle, 0) * CFrame.new(0, 0, 25)).p)
local End = ((Part.CFrame)* (CFrame.Angles(0, Angle, 0) * CFrame.new(0, 0, 1000)).p)
local Ray1 = Ray.new(Start, End.unit).Unit
local part,endPoint = Workspace:FindPartOnRay(Ray1,Part)
if part then
TestLine(Start,End,"Bright Blue")
TestLine(Start,endPoint,"Bright Red")
TestPart(endPoint)
end
end
end

Basically, TestLine(Pos1,Pos2,[[color]]) creates a line between 2 points so i can see, and TestPart(Pos) creates a part at a position, its just a form of debugging

The Blue test line (showing where the ray should go from start to finish) draws correctly, and the Red test line (showing where the ray is going) is only about 1 stud long (EVERY TIME) and doesnt go in both the right direction, anyone have any ideas how to fix?
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
05 Oct 2011 06:23 PM
"local Ray1 = Ray.new(Start, End.unit).Unit"
".Unit"

That makes the ray only 1 stud long. :I

Also, I think you might be using the second argument wrong. Try End-Start instead of what you have, and see what happens.
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:25 PM
FUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUUU i thought i removed that, and okay, thanks
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:28 PM
and im pretty sure its Ray.new(Origin, Direction)
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:29 PM
flipping it End-Start didnt work :/
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
05 Oct 2011 06:35 PM
it's either

Ray.new(origin, difference between end and origin)

or

Ray.new(origin, unit direction * distance)
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:38 PM
ill try both... and hey look, i have a Lua hat!
:D
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
05 Oct 2011 06:41 PM
i have a lua top hat

i win
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:45 PM
thats what it is. therefore we draw! :D
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:49 PM
you seemed to be right with (origin,end.unit*distance) but now its showing some more... harder to explain results... is posting links to images against the rules? i forget. else i could screenshot it and show you whats happening with the rays
Report Abuse
crazypotato4 is not online. crazypotato4
Joined: 22 Feb 2010
Total Posts: 20000
05 Oct 2011 06:53 PM
if the image is on roblox then its fine
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 06:58 PM
wait ive just realised, and its easy to explain now, all the proper ray traces are pointing in the same direction, and they all seem to be more or less parralel to each other, it seems the origin is correct, and then distance is correct, they even hit objects correctly, though they are not angled correctly... hmm...
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 07:00 PM
oh wait, you was doubly right, its BOTH the things you said, its ray.new(origin,(Difference between start and origin) * distance

Thanks for yoru help man! :)
Report Abuse
ownage94 is not online. ownage94
Joined: 11 Dec 2008
Total Posts: 375
05 Oct 2011 07:02 PM
i actually cant thankyou enough, ive been trying to fix this for ages lol, someone should re-write the wiki page on raycasting its not very clear
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