|
| 24 May 2012 04:00 PM |
Hi, I would need a short lesson in raycasting. Just tell me how to "shoot" the ray into a described part, and how to get the "hit"`s name!
Please, Im desperate. |
|
|
| Report Abuse |
|
|
MrMcAero
|
  |
| Joined: 21 Apr 2012 |
| Total Posts: 671 |
|
|
| 24 May 2012 04:21 PM |
Well, the rayCast method does not actually create a part and place it to two places. It creates a fake imaginary line. Look here for weapon tuts:
http://wiki.roblox.com/index.php/How_to_Make_a_Raycasting_Lasergun
MrMcAero |
|
|
| Report Abuse |
|
|
|
| 24 May 2012 04:29 PM |
Haha, looks like MrMcAero beat me to posting that link there. Yea, try checking wiki.roblox.com. It is really helpful. :) Check the "See Also" links as well as the page to the following link:
http://wiki.roblox.com/index.php/Raycast
`FlightTheory |
|
|
| Report Abuse |
|
|
|
| 24 May 2012 04:45 PM |
Take Speed AI from the Catalog,
Or How to make a Laser gun from the wiki:
http://wiki.roblox.com/index.php/How_to_Make_a_Raycasting_Lasergun
local Ray = Ray.new(OriginPart.p, (OriginPart.Position - Destination.Part.Position) .unit*300) --Make the ray.
-- 300 is the length of the ray from OriginPart. ( I have never had luck putting a variable, aside form a Constant there)
" "shoot" the ray into a described part" -- here it sounds more like you are drawing the ray. Found in Laser Gun
This is how to geet the Name.
local Hit,Position = game.Workspace:FindPartOnRay(Ray,MODEL) --Check for collisions along the ray.
--Make MODEL (Parts to ignore) the model (Parent) of the OriginPart, or just the OriginPart. --After that line Hit will be, the first Part that it hit.
--Position wil be where the Ray hit.
--Brian
if Hit then --If it hits something. if Hit.Parent:FindFirstChild("Humanoid") |
|
|
| Report Abuse |
|
|
|
| 24 May 2012 04:50 PM |
sorry didn't finish:
Name:
if Hit then --If it hits something. (If not nil (We didn't hit anything))
print("Name of part hit (Parent) = ", Hit.Name, Hit, Hit.Parent)
|
|
|
| Report Abuse |
|
|