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 |
|
|
|
| 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
|
  |
| 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
|
  |
| 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
|
  |
| Joined: 11 Dec 2008 |
| Total Posts: 375 |
|
|
| 05 Oct 2011 06:29 PM |
| flipping it End-Start didnt work :/ |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
| |
|
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
|
  |
| 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 |
|
|
|
| 05 Oct 2011 06:53 PM |
| if the image is on roblox then its fine |
|
|
| Report Abuse |
|
|
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
|
  |
| 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
|
  |
| 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 |
|
|