generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Beginner Raycaster here

Previous Thread :: Next Thread 
StealthKing95 is online. StealthKing95
Joined: 13 Dec 2008
Total Posts: 4263
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 is not online. 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
FlightTheory is not online. FlightTheory
Joined: 29 Sep 2011
Total Posts: 156
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
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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
BJCarpenter is not online. BJCarpenter
Joined: 04 Nov 2008
Total Posts: 4416
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image