|
| 03 Apr 2015 12:58 AM |
I lost the thread though, ugh..
can someone give a good explanation |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 01:01 AM |
Raycast casts an invisible ray that isn't a part or an instance, but is basically a two dimensional mush of some properties.
The ray beginning, end, & if you compare the two values you can get the ray length, magnitude, center etc.
You also have the ability to findpartonray allowing you to collect tables of parts that the ray is merged into, you also have the ability to use the ignore list addition to have instances that are ignored by the ray and not returned in the table. |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 01:03 AM |
| so give me an example of Ray.new() and FindPartOnRay() |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 01:10 AM |
Ray.new(Vector3.new(), Vector3.new()) casts a ray linearly between the two vectors
local R = Ray.new(Vector3.new(0, 69, 0), Vector3.new(0, 0, 0))
This will cast a ray between 0, 69, 0 and 0, 0, 0
local P = Workspace:FindPartOnRay(R, Ignore)
This will find any parts that the ray collides into, unless it is the Ignore instance
Workspace:FindPartOnRayWithIgnoreList(R, Ignore) allows more than a single instance to ignore.
|
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 01:18 AM |
| wait... so how would you "draw" a ray.. so it shows up? |
|
|
| Report Abuse |
|
|
chimmihc
|
  |
| Joined: 01 Sep 2014 |
| Total Posts: 17143 |
|
|
| 03 Apr 2015 01:23 AM |
local part,pos = game.Workspace:FindPartOnRay(ray,ignore)
local shot = Instance.new("Part")
shot.CFrame = CFrame.new((pos - startPos).Unit*HalfOfRayLength,startPos) shot.Size = Vector3.new(1,1,Raylength)
-- add some maths to that and you are good
I script -~ chimmihc |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 01:28 AM |
I used to have that same question, here's the answer
local V1, V2 = Vector3.new(0,5,0), Vector3.new(0,20,0) local R = Ray.new(V1, (V2 - V1).Unit * 100) local H, P = Workspace:FindPartOnRay(R) local D = (P - V1).magnitude
local Part = Instance.new('Part', Workspace) Part.Anchored, Part.FormFactor, Part.Name, Part.Size, Part.CFrame = true, Enum.FormFactor.Custom, 'Ray', Vector3.new(.2, .2, D), CFrame.new(P, V1) * CFrame.new(0, 0, -D/2), BrickColor.new('Really red') |
|
|
| Report Abuse |
|
|
|
| 03 Apr 2015 01:29 AM |
| how do u figure out how long the ray is |
|
|
| Report Abuse |
|
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 01:32 AM |
Just use my fang' m8 <3
feel free 2 chainj the vectors tho |
|
|
| Report Abuse |
|
|
| |
|
mycheeze
|
  |
| Joined: 27 Jun 2011 |
| Total Posts: 6748 |
|
|
| 03 Apr 2015 01:37 AM |
local V1, V2 = Vector3.new(0,5,0), Vector3.new(0,20,0) local R = Ray.new(V1, (V2 - V1).Unit * 100) local H, P = Workspace:FindPartOnRay(R) local D = (P - V1).magnitude
local Part = Instance.new('Part', Workspace) Part.Anchored, Part.FormFactor, Part.Name, Part.Size, Part.CFrame = true, Enum.FormFactor.Custom, 'Ray', Vector3.new(.2, .2, D), CFrame.new(P, V1) * CFrame.new(0, 0, -D/2), BrickColor.new('Really red')
Part = The 'Drawn' Ray, V1, V2 = begin point, end point R = the ray
H = hek, I 4got
P = The first collision
D = The comparing of the hit area (or the end point if there was no collision) and the beggining, then converted to a magnitude to make a size |
|
|
| Report Abuse |
|
|