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: FindPartsInRegion3 Method

Previous Thread :: Next Thread 
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
19 Dec 2012 06:25 PM
I am using the FindPartsInRegion3 method along with raycasting, so I can identify all of the pieces that touch the ray. It works some of the time, but not all of the time. What I mean by this is that it sometimes says it isn't touching anything, when it actually is, and vice versa. Is there a fix for this? Or better yet, an alternative way to do this?
What I am trying to do is identify if there are any CanCollide = true bricks between to points. Thanks in advance for any help.
Report Abuse
Moolah60 is not online. Moolah60
Joined: 26 Sep 2009
Total Posts: 654
19 Dec 2012 06:41 PM
Instead of using :FindPartsInRegion3() why don't you use the :FindPartOnRay() method? That way it'd only detect parts on the actual ray, not outside of it.
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
19 Dec 2012 06:45 PM
Please correct me if I'm wrong, but doesn't the :FindPartOnRay() method only identify the first part it touches?
Report Abuse
Moolah60 is not online. Moolah60
Joined: 26 Sep 2009
Total Posts: 654
19 Dec 2012 06:52 PM
Yes but I believe that :FindPartsInRegion3() works similarly. Maybe instead of that you can do this:

function newRay(pos)
local ray = Ray.new(pos, (game.Workspace.Part.Position - pos).unit * 500)
if game.Workspace:FindPartOnRay(ray) then
local part,pos = game.Workspace:FindPartOnRay(ray)
if part.CanCollide = true then
-- your script here
end
newRay(pos)
end end

newRay(Vector3.new(0,0,0))


--game.Workspace.Part is the ending position.
Report Abuse
Moolah60 is not online. Moolah60
Joined: 26 Sep 2009
Total Posts: 654
19 Dec 2012 06:55 PM
Well I made an error and forgot an equal sign where it checks for CanCollide true, here's the fixed script.

function newRay(pos)
local ray = Ray.new(pos, (game.Workspace.Part.Position - pos).unit * 500)
if game.Workspace:FindPartOnRay(ray) then
local part,pos = game.Workspace:FindPartOnRay(ray)
if part.CanCollide == true then
-- your script here
end
newRay(pos)
end end

newRay(Vector3.new(0,0,0))


--game.Workspace.Part is the ending position.
Report Abuse
Moolah60 is not online. Moolah60
Joined: 26 Sep 2009
Total Posts: 654
19 Dec 2012 06:57 PM
Man I'm really off right now, I had two of the same values called in the script(pos was used twice..) hah sorry about that.

function newRay(nPos)
local ray = Ray.new(nPos, (game.Workspace.Part.Position - nPos).unit * 500)
if game.Workspace:FindPartOnRay(ray) then
local part,pos = game.Workspace:FindPartOnRay(ray)
if part.CanCollide == true then
-- your script here
end
newRay(pos)
end end

newRay(Vector3.new(0,0,0))


--game.Workspace.Part is the ending position.
Report Abuse
RoyStanford is not online. RoyStanford
Joined: 21 Oct 2008
Total Posts: 2222
19 Dec 2012 07:14 PM
Although I didn't use that exact code, it gave me an idea that fixed my problem. Thanks!
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