|
| 17 Apr 2016 12:05 PM |
Ok heres whats up. I'm terrible with raycasting. I'm just here because I need a single function written. I don't care if you try to help teach me about raycasting, I get the concept and how it works. I just don't know the code to write. basically:
MouseButton2Down:connect(function() send out ray from part, script.Parent.TRGT, in the direction of lookvector if ray hits a part called streak then wait(2.5) if mousebutton2 still down then script.Parent.Variables.Lock.Value = true end end end)
and i guess on button2 up i'll just make lock = false. |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2016 12:06 PM |
| I suppose i should specify if can be, make the ray the same width and height of part TRGT |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2016 12:07 PM |
| and the ray should travel infinite distance |
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 17 Apr 2016 12:11 PM |
Ray.new(start,direction)
Rays don't have a width or height, they're just a lil beam shot out in a direction
Try this: local ignorelist = {} --change to things for ray to ignore, like the part itself and the player
local hit,pos = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(part.CFrame.p,(part.CFrame.lookVector).unit*9999,ignorelist)
if hit~= nil then if hit.Name == "streak" then
you figure out the rest |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2016 12:13 PM |
| thank you klga, do i need to stop the ray? how would i if needed? |
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 17 Apr 2016 12:14 PM |
| I don't know of a way to do it if it is possible, but the ray just goes until it hits something or it reaches the end of it's direction |
|
|
| Report Abuse |
|
|
| |
|
|
| 17 Apr 2016 12:16 PM |
Read up on this tutorial: http://wiki.roblox.com/index.php?title=Making_a_ray-casting_laser_gun
Replace the line if you want to fire rays with lookVector: local ray = Ray.new(tool.Handle.CFrame.p, tool.Handle.CFrame.lookVector* 300)
Aswell look at this under Usage for the limitations: http://wiki.roblox.com/index.php?title=API:Class/Workspace/FindPartOnRay |
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 17 Apr 2016 12:20 PM |
| They don't really glide across the world, they're fast if not instant, it basically just looks in the specified direction until it hits something |
|
|
| Report Abuse |
|
|
|
| 17 Apr 2016 02:57 PM |
| KLGA argument2 is nil with your function |
|
|
| Report Abuse |
|
|
KLGA
|
  |
| Joined: 19 Apr 2014 |
| Total Posts: 2571 |
|
|
| 18 Apr 2016 01:46 PM |
Forgot a parenthesis
local hit,pos = game.Workspace:FindPartOnRayWithIgnoreList(Ray.new(part.CFrame.p,(part.CFrame.lookVector).unit*9999),ignorelist) |
|
|
| Report Abuse |
|
|