yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 07 Mar 2015 03:18 PM |
I want it so when one brick touches another a raycast will fire out of a brick towards the brick that touched the brick. Here is what i have so far
local Shooter = script.Parent local Radius = script.Parent.Parent.Radius
Radius.Touched:connect(function(hit) local ray = Ray.new(Shooter, hit) local hit, position = game.Workspace:FindPartOnRay(ray, hit) local distance = (position - Shooter.Position).magnitude local rayPart = Instance.new("Part", Shooter) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright red") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(position, Shooter.Position) * CFrame.new(0, 0, -distance/2)
--add it to debris so it disappears after 0.1 seconds game.Debris:AddItem(rayPart, 5) end) |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
|
| 07 Mar 2015 04:08 PM |
| local ray = Ray.new(Shooter.Position, (hit.Position - Shooter.Position).unit) |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 07 Mar 2015 04:10 PM |
| Thanks, no errors but it doesnt draw a ray |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 07 Mar 2015 04:13 PM |
| The ray is being created but is not visible, something wrong with distance or position? |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 07 Mar 2015 04:15 PM |
| Distance is the dodgy variable, i did some debugging but i dont know how to fix it |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
|
| 07 Mar 2015 04:48 PM |
| It only changes the position on the Z axis. You want to get the midpoint of all three axes separately and set the position to that. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 07 Mar 2015 04:52 PM |
| Sorry, i got no sense of that(im an idiot) In lua what would that be like? |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2015 05:11 PM |
| King, his code is correct on all axes as far as I can see. |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2015 05:15 PM |
> King, his code is correct on all axes as far as I can see. > ... * CFrame.new(0, 0, -distance/2)
That moves it only to the midpoint of the Z axis. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
|
| 07 Mar 2015 06:14 PM |
*Facepalm* It only NEEDS to be moved to the midpoint on the Z axis. It is already at the midpoint on the others. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 07 Mar 2015 06:21 PM |
| So what i have is already correct? |
|
|
| Report Abuse |
|
|
|
| 07 Mar 2015 09:27 PM |
> It only NEEDS to be moved to the midpoint on the Z axis. It is already at the midpoint on the others.
What the heck are you talking about? He currently sets it at the position it hit at and then arbitrarily messes with the Z axis. If I shoot it straight down the X axis with a distance of 50, it will go to the position that it hit and then 25 studs to the left, nowhere near where it's supposed to be. |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
| |
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 08 Mar 2015 05:32 AM |
Radius.Touched:connect(function(hit) local ray = local ray = Ray.new(Shooter.Position, (hit.Position - Shooter.Position).unit) local hit, position = game.Workspace:FindPartOnRay(ray, hit) local distance = (position - Shooter.Position).magnitude local rayPart = Instance.new("Part", Shooter) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright red") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(Vector3.new(), Shooter.Position- position) + (Shooter.Position+ position)/2
--add it to debris so it disappears after 0.1 seconds game.Debris:AddItem(rayPart, 5) end) |
|
|
| Report Abuse |
|
|
yobo89
|
  |
| Joined: 05 Jun 2010 |
| Total Posts: 2341 |
|
|
| 08 Mar 2015 05:35 AM |
Still no ray beign drawn local Shooter = script.Parent.Parent.Shooter local Radius = script.Parent
Radius.Touched:connect(function(hit) print("Worked") local ray = Ray.new(Shooter.Position, (hit.Position - Shooter.Position).unit) local hit, position = game.Workspace:FindPartOnRay(ray, hit) local distance = (position - Shooter.Position).magnitude local rayPart = Instance.new("Part", Shooter) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright red") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(Vector3.new(), Shooter.Position- position) + (Shooter.Position+ position)/2
--add it to debris so it disappears after 0.1 seconds game.Debris:AddItem(rayPart, 5) end)
|
|
|
| Report Abuse |
|
|
Casualist
|
  |
| Joined: 26 Jun 2014 |
| Total Posts: 4443 |
|
|
| 08 Mar 2015 05:44 AM |
local Shooter = script.Parent.Parent.Shooter local Radius = script.Parent local maxDistance = 100 Radius.Touched:connect(function(hit) print("Worked") local ray = Ray.new(Shooter.Position, (hit.Position - Shooter.Position).unit*maxDistance) local hit, position = game.Workspace:FindPartOnRayWithIgnoreList(ray, {Shooter}) print(hit, position) local distance = (position - Shooter.Position).magnitude local rayPart = Instance.new("Part", Shooter) rayPart.Name = "RayPart" rayPart.BrickColor = BrickColor.new("Bright red") rayPart.Transparency = 0.5 rayPart.Anchored = true rayPart.CanCollide = false rayPart.TopSurface = Enum.SurfaceType.Smooth rayPart.BottomSurface = Enum.SurfaceType.Smooth rayPart.formFactor = Enum.FormFactor.Custom rayPart.Size = Vector3.new(0.2, 0.2, distance) rayPart.CFrame = CFrame.new(Vector3.new(), Shooter.Position- position) + (Shooter.Position+ position)/2
--add it to debris so it disappears after 0.1 seconds game.Debris:AddItem(rayPart, 5) end) |
|
|
| Report Abuse |
|
|