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
 

Re: Making a ray infinite in one direction?

Previous Thread :: Next Thread 
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:24 PM
How would I do that?
castRay(script.Parent.Torso.Position,nil)
The starting position is the Torso, and I don't know to make it infinite in the direction the Torso is facing.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
08 Sep 2013 01:27 PM
Will you be making a brick go in the direction of the ray? Like a Laser?
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:28 PM
Yeah pretty much... I'm just seeing if I can make an AI, and for a good one you may need to use a ray.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
08 Sep 2013 01:29 PM
I also wonder about this. This is what he wants.



A ray starts from the torso.
The ray will remain at the same lookVector as the torso.
The ray never ends.
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
08 Sep 2013 01:29 PM
Bricks have a size limit. It can't be infinite.
Report Abuse
Bebee2 is not online. Bebee2
Joined: 17 May 2009
Total Posts: 3985
08 Sep 2013 01:30 PM
Well, yeah. Let's just say '2000.'
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:31 PM
Yes, but how do I put that in terms for my script? If I leave the second argument nil then I get an error.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
08 Sep 2013 01:31 PM
make it math.huge lelelel
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:32 PM
I'm not making a brick for it, I'm just using a ray, and as far as I know a ray is finite in one direction and infinite in the other. So therefore, it can be infinite.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
blobbyblob is not online. blobbyblob
Joined: 29 Oct 2008
Total Posts: 12165
08 Sep 2013 01:34 PM
Do you want the ray to stop if it hits something, or just continue through all other parts?

If it goes through all parts, then:

local origin, direction = Torso.Position, Torso.CFrame.lookVector;
part.CFrame = CFrame.new(origin + direction.unit * part.Size.z / 2, origin);

Make it elongated along the z axis.
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:36 PM
What I wanted was it to be infinite in one direction and detects if it hits something. So it can go as far as it wants to and still looks for an object to hit.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:39 PM
Basically, I want the ray to be infinite in ONLY the direction the torso is facing, I tried the lookVector of the torso, but that just seemed to find the BasePlate no matter where I positioned a block.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
ZachBloxx is not online. ZachBloxx
Joined: 26 Jun 2013
Total Posts: 2833
08 Sep 2013 01:40 PM
local hit = Workspace:FindPartOnRay(ray)
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:41 PM
Never mind, I fixed it. I just needed to make the second argument 0,0,0. Go figure...

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:42 PM
function castRay(start,End)
local ray = Ray.new(start, (End - start).unit*-500)
local hit,pos = game.Workspace:FindPartOnRay(ray,script.Parent)
if hit then
print(hit.Name)
end
end

while wait() do
castRay(script.Parent.Torso.Position,Vector3.new(0,0,0))
end

That's what I was using. I just posted the call of the function because that was my only problem basically.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
Report Abuse
chris1989 is not online. chris1989
Joined: 30 Nov 2007
Total Posts: 2520
08 Sep 2013 01:47 PM
LookVector is probably set up wrong havent used it in awhile.

local ray = Ray.new(ai.Torso.Position, ai.Torso.LookVector * 2000)
local part, endpoint = workspace:FindPartOnRay(ray)
if Part then
--stuff
end
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
08 Sep 2013 01:54 PM
Chris, thanks works even better now, :P.

"U BROKE THE TV U IDIOT!" - CeaselessSoul
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