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 » Scripters
Home Search
 

Re: Someone explained Raycast really... REAALLY good a while ago

Previous Thread :: Next Thread 
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
03 Apr 2015 12:58 AM
I lost the thread though, ugh..

can someone give a good explanation
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 01:01 AM
Raycast casts an invisible ray that isn't a part or an instance, but is basically a two dimensional mush of some properties.

The ray beginning, end, & if you compare the two values you can get the ray length, magnitude, center etc.

You also have the ability to findpartonray allowing you to collect tables of parts that the ray is merged into, you also have the ability to use the ignore list addition to have instances that are ignored by the ray and not returned in the table.
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
03 Apr 2015 01:03 AM
so give me an example of Ray.new() and FindPartOnRay()
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 01:10 AM
Ray.new(Vector3.new(), Vector3.new()) casts a ray linearly between the two vectors

local R = Ray.new(Vector3.new(0, 69, 0), Vector3.new(0, 0, 0))

This will cast a ray between 0, 69, 0 and 0, 0, 0

local P = Workspace:FindPartOnRay(R, Ignore)

This will find any parts that the ray collides into, unless it is the Ignore instance

Workspace:FindPartOnRayWithIgnoreList(R, Ignore) allows more than a single instance to ignore.

Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
03 Apr 2015 01:18 AM
wait... so how would you "draw" a ray.. so it shows up?
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
03 Apr 2015 01:23 AM
local part,pos = game.Workspace:FindPartOnRay(ray,ignore)

local shot = Instance.new("Part")

shot.CFrame = CFrame.new((pos - startPos).Unit*HalfOfRayLength,startPos)
shot.Size = Vector3.new(1,1,Raylength)

-- add some maths to that and you are good


I script -~ chimmihc
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 01:28 AM
I used to have that same question, here's the answer

local V1, V2 = Vector3.new(0,5,0), Vector3.new(0,20,0)
local R = Ray.new(V1, (V2 - V1).Unit * 100)
local H, P = Workspace:FindPartOnRay(R)
local D = (P - V1).magnitude

local Part = Instance.new('Part', Workspace)
Part.Anchored, Part.FormFactor, Part.Name, Part.Size, Part.CFrame = true, Enum.FormFactor.Custom, 'Ray', Vector3.new(.2, .2, D), CFrame.new(P, V1) * CFrame.new(0, 0, -D/2), BrickColor.new('Really red')
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
03 Apr 2015 01:29 AM
how do u figure out how long the ray is
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 01:32 AM
Just use my fang' m8 <3

feel free 2 chainj the vectors tho
Report Abuse
AbstractMadness is not online. AbstractMadness
Joined: 22 Dec 2014
Total Posts: 20425
03 Apr 2015 01:32 AM
u dont tab ur code ;c
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
03 Apr 2015 01:37 AM
local V1, V2 = Vector3.new(0,5,0), Vector3.new(0,20,0)
local R = Ray.new(V1, (V2 - V1).Unit * 100)
local H, P = Workspace:FindPartOnRay(R)
local D = (P - V1).magnitude

local Part = Instance.new('Part', Workspace)
Part.Anchored, Part.FormFactor, Part.Name, Part.Size, Part.CFrame = true, Enum.FormFactor.Custom, 'Ray', Vector3.new(.2, .2, D), CFrame.new(P, V1) * CFrame.new(0, 0, -D/2), BrickColor.new('Really red')

Part = The 'Drawn' Ray, V1, V2 = begin point, end point
R = the ray

H = hek, I 4got

P = The first collision

D = The comparing of the hit area (or the end point if there was no collision) and the beggining, then converted to a magnitude to make a size
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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