superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 23 Aug 2012 08:01 PM |
while wait(.1) do
local ray = Ray.new(script.Parent.Torso.CFrame.p,getPlayer(script.Parent.Torso.Position).CFrame.lookVector)
local part = workspace:findPartOnRay(ray)
--getPlayer(position) returns a Torso.
if part then
print("Wall") else
print("!Wall!")
end
end
I'm almost positive I'm coding it correctly, but it only prints "!Wall!" when there is, in fact, a part intersecting. If I'm not coding it correctly, then please tell me. |
|
|
| Report Abuse |
|
|
| |
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
| |
|
| |
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
| |
|
|
| 23 Aug 2012 08:07 PM |
| I'm only good with ray casting guns.. XD. |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 23 Aug 2012 08:07 PM |
@Cease, Outside of it he could have a mousebutton1Down/Up function. |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 23 Aug 2012 08:09 PM |
Well I used:
Spawn(function()) --loop end)
I don't want to post the rest of my script, it works fine. |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 23 Aug 2012 08:11 PM |
Okay, Guess it is AI, GOOOD LUCK! |
|
|
| Report Abuse |
|
|
| |
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 23 Aug 2012 08:14 PM |
| What? Why? Anyway, I need help please. :3 |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 23 Aug 2012 08:14 PM |
@Bobby, For what, just because I stated a fact that you're a low life piece of scum? |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2012 08:15 PM |
What did I ever do to you lol I just said reported. |
|
|
| Report Abuse |
|
|
mamaguy
|
  |
| Joined: 07 Oct 2010 |
| Total Posts: 7073 |
|
|
| 23 Aug 2012 08:16 PM |
| You scammed my friend, and flamed me. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2012 08:17 PM |
| What items did I take, and I never flamed you. ALL you ever do is just look where I post, and then flame me. You got your clockwork headphones, now stop Q_Qing, k? Thanks. |
|
|
| Report Abuse |
|
|
|
| 23 Aug 2012 08:20 PM |
"getPlayer(script.Parent.Torso.Position).CFrame.lookVector)"
Mind explaining the getPlayer function? |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 23 Aug 2012 08:26 PM |
getPlayer(pos) finds the nearest Torso.
getPlayer(pos).CFrame.lookVector is the lookVector of the Torso. |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 23 Aug 2012 08:33 PM |
| Well, the direction it is facing. |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 23 Aug 2012 10:21 PM |
| Bump bump bump, bump-it-up! |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
| |
|
|
| 24 Aug 2012 12:09 AM |
Filter frustration part 1/3: Raycasts only work as far as the magnitude of the second argument, so the function is only looking for parts 1/2 a brick away from your torso XD
|
|
|
| Report Abuse |
|
|
|
| 24 Aug 2012 12:10 AM |
Do this:
local pos=script.Parent.Torso.CFrame.p local tor=getPlayer(pos) local ray=Ray.new(pos,tor.CFrame.lookVector*((tor.Position-pos).magnitude+tor.Size.magnitude/2))
|
|
|
| Report Abuse |
|
|
|
| 24 Aug 2012 12:11 AM |
That way, the ray will go to at least the distance between them, + the part's size in case it's at an odd angle. (end of filter frustration, I don't know what the problem was) |
|
|
| Report Abuse |
|
|
|
| 24 Aug 2012 12:24 AM |
| try that first, and if it doesn't work, try putting a - before the second argument, as lookVector actually returns a negated unitVector (lolwhy?) |
|
|
| Report Abuse |
|
|
superior
|
  |
| Joined: 13 Apr 2008 |
| Total Posts: 1662 |
|
|
| 24 Aug 2012 10:17 AM |
| How would I make it so that the ray always goes to the player? Right now, the ray goes in the direction the players torso is, so if the player turns around, the ray checks opposite of the start position. ? |
|
|
| Report Abuse |
|
|