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
 

raycasting issue.

Previous Thread :: Next Thread 
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
10 May 2012 09:47 PM
this is supposed to raycast to a point and check if anything is blocking a direct path to it. However even when there is a clear path it returns false. With all the extra debugging and prints i thrown in there i've come to notice that its casting rays much higher above the point(node) and the torso, so there must be something wrong with the raycasting. Halp?


function checkPath(node)
        wait()
        local ray = Ray.new(torso.Position,node.Position)
        local hit,pos = Workspace:FindPartOnRay(ray,script.Parent)
        if hit and hit ~= node then
                mag = (pos - torso.Position).magnitude
                print(node.Name..": invalid - ",hit,">",hit.Parent," | "..mag)
                hit.BrickColor = BrickColor.new("Really blue") -- color hit part blue for testing.
                return false
        elseif hit == node or hit == destination then
                print(node.Name..": Valid - ",hit)
                return true
        end
end
Report Abuse
Candymaniac is not online. Candymaniac
Joined: 08 Oct 2009
Total Posts: 8985
11 May 2012 01:29 AM
local Ray = Ray.new(torso.CFrame.p, (node.CFrame.p - torso.CFrame.p).unit*300)
local Hit, Position = game.Workspace:FindPartOnRay(Ray, script.Parent)

☜▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☜☆☞▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬▬☞ - Candymaniac, a highly reactive substance.
Report Abuse
MrgamesNwatch is not online. MrgamesNwatch
Joined: 02 Feb 2009
Total Posts: 7729
11 May 2012 02:03 PM
o____o thank you so much! That fixed it! It works perfectly :D :D :D i give you +9001 internets, 1337 cookies and an ever so manly brofist.
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