kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 09:23 PM |
Okay well there really is no SET thing wear it goes so I copied it off the Wiki, read a little and made this. What I want to do is send a ray from the Person's torso straight to wear they are faceing. "Not a player"
] local ray = Ray.new( script.Parent.Torso.Position, script.Parent.Torso.Position + Vector3.new()-- What do I put here? ) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 09:25 PM |
local ray = Ray.new( script.Parent.Torso.Position, script.Parent.Torso.CFrame.lookVector ) |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 09:26 PM |
| torso.Postion + torso.CFrame.lookVector*distance |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
| |
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 09:35 PM |
Okay so I have this and how do I tell if the ray Hits a part?
local ray = Ray.new( Torso.Position, Torso.Position + Torso.CFrame.lookVector*distance ) local block, endPoint = Workspace:FindPartOnRay(ray) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Dec 2013 09:38 PM |
Ray.new is a function that takes 2 arguments: start position (Vector3) and direction (Vector3)
In this case, direction's magnitude is the length it travels.
In your script, the block is if it hits a part, so: if block then print("It hit: ", block) end |
|
|
| Report Abuse |
|
|
|
| 27 Dec 2013 09:41 PM |
@evolved
I wasn't showing the whole CFrame part of it, only the second half. And even if I was doing that adding a comma wouldn't work.
local cf = part.Position CFrame.new(cf.p, cf.p + cf.lookVector) |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 09:46 PM |
Okay well it wasn't printing so I was thinking it wasn't working because I didn't set a distance.
This is what I have, I changed block to part because it might be easier to use the wiki.
local ray = Ray.new( Torso.Position, Torso.CFrame.lookVector ) local part, endPoint = Workspace:FindPartOnRay(ray) if part then print("it hit:", part) end |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 09:49 PM |
Whats this?
Workspace:FindPartOnRay(ray) |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Dec 2013 09:49 PM |
"Torso.CFrame.lookVector" It is going 1 stud, from the center, so the chances of hitting anything are very low |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 09:50 PM |
| Well, hoe do I change it from going from 1 stud to going 7 studs. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 10:00 PM |
Okay Thank you!
I have made a Person that walks randomly and doesn't walk into walls. |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 10:08 PM |
| Okay one question. Can anyone calculate how many studs someone can move at a walk speed of 10? |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Dec 2013 10:09 PM |
| Yes, walkspeed of 10 is 10 studs/second. |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 10:11 PM |
| Thats how they did it? That will make this a lot easier to calculate with the speed of the person. AKA running. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Dec 2013 10:12 PM |
well speed = distance/time So if you want to get the distance they go in given time and speed (assuming this is constant)
distance = speed * time distance = 10 studs/second * 5 seconds distance = 50 studs
|
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 10:17 PM |
Okay so the walking away from the part is not working..
I have this and I had no idea what I was doing when I made it.. which was like 3 minutes ago. "block is the part that the humanoid moves to"
block.CFrame = Torso.CFrame - Torso.CFrame.lookVector*-Dis |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Dec 2013 10:18 PM |
What is block? Are you trying to set it in front of the torso, if so: block.CFrame = Torso.CFrame * CFrame.new(0, 0, -Distance) |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 10:20 PM |
In the random movment script that I made 90% of and the other is from scripting helpers 'Thank you'
Anyway It makes a brick, moves it to a random position with a givent distance, than I move the humanoid it it and remove the block and do it over that over.
Anyway the part the humanoid moves to is block. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 27 Dec 2013 10:21 PM |
Alright, so is there a problem? You should probably place it at random.
Block.CFrame = Torso.CFrame * CFrame.new(math.random(-50, 50), 0, math.random(-50, 50)) |
|
|
| Report Abuse |
|
|
kingmatt2
|
  |
| Joined: 20 Aug 2011 |
| Total Posts: 6494 |
|
|
| 27 Dec 2013 10:24 PM |
| No I mean it is placed random but I want it to be places the opposite the torso is facing if a part is within a certain distance. |
|
|
| Report Abuse |
|
|