digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 29 Jun 2013 05:26 AM |
I'm currently having some trouble raycasting.
I'm raycasting from my character's head pointed at the Camera's CoordinateFrame, if you ask where I'm raycasting.
For some reason, my ray picks up my character's Hats perfectly fine and adjusts it (which I need to fix too, but current though it to just remove them completely) and it doesn't detect the parts I want it to - which is the terrain. |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 29 Jun 2013 05:27 AM |
Whoops, forgot to provide the script's source. Here's the part that matters:
game:GetService("RunService").Stepped:connect( function() cam.CameraSubject = char.Head cam.CameraType = "Scriptable" cam.CoordinateFrame = CFrame.new(char.Head.CFrame.p + Vector3.new(-5, 15, 30), char.Head.CFrame.p) local hitRay = Ray.new(char.Head.CFrame.p, (cam.CoordinateFrame.p - char.Head.CFrame.p).unit) local part, hit = workspace:FindPartOnRay(hitRay) --,char:GetChildren()) local dist=0 if part then dist = (hit - char.Head.CFrame.p).magnitude print(dist) end cam.CoordinateFrame = CFrame.new(char.Head.CFrame.p + Vector3.new((-5 + dist), (15 - dist), (30 + dist)), char.Head.CFrame.p) if not active then char.Torso.CFrame = CFrame.new(char.Torso.CFrame.p,Vector3.new(mouse.Hit.p.X, char.Torso.CFrame.p.Y, mouse.Hit.p.Z)) end end )
All variables have been defined, as that's just a snippet. |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 29 Jun 2013 05:28 AM |
also, should've made myself clearer.
By 'terrain' I didn't mean the Terrain object, I meant the building that I had done around the spawn I had put in. |
|
|
| Report Abuse |
|
|
bourlo
|
  |
| Joined: 11 Aug 2009 |
| Total Posts: 399 |
|
|
| 29 Jun 2013 05:43 AM |
So does it always return your hats? FindPartOnRay () returns only the first part it finds on a ray,if that part is one of your hats then you can't get the terrain you want unless you ignore the character. local part, hit = workspace:FindPartOnRay(hitRay,char) |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 29 Jun 2013 05:59 AM |
I got it to work :D
Apparently it was only checking a small area, so I fixed it so it didn't.
I also fixed the hats.
:D |
|
|
| Report Abuse |
|
|
Infocus
|
  |
| Joined: 28 Apr 2011 |
| Total Posts: 8022 |
|
|
| 29 Jun 2013 07:33 AM |
| I thought .Stepped was deprecated? |
|
|
| Report Abuse |
|
|
|
| 29 Jun 2013 11:30 AM |
| @Infocus - So is :Remove(), but it works better than :Destroy() at times. |
|
|
| Report Abuse |
|
|