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: How would I detect when something crosses a ray?

Previous Thread :: Next Thread 
TheWisest is not online. TheWisest
Joined: 11 Nov 2010
Total Posts: 7345
31 May 2014 02:38 PM
In ray casting, say whenever someone walks in front of where the 'ray' is, it performs a event.

It seems pretty basic, but I can't seem to figure it out (I already know how to cast the ray itself, it is just this that I need help with)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 May 2014 02:39 PM
The "FindPartOnRay" gives you the position and the part of what it hit.
Report Abuse
TheWisest is not online. TheWisest
Joined: 11 Nov 2010
Total Posts: 7345
31 May 2014 02:46 PM
So could I do something like this?


par = script.Parent

Ray.new(par.Position, par.CFrame.lookVector * 500)

local hit, position = game.Workspace:FindPartOnRay(ray)

print(hit)

I already tried this and it didn't work and the output is giving me nothing.



Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
31 May 2014 02:47 PM
You didn't define ray

ray = Ray.new(par.Position, par.CFrame.lookVector * 500)
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 May 2014 02:50 PM
Maybe it is not hitting anything, print position, hit

And also, define ray as island said
Report Abuse
TheWisest is not online. TheWisest
Joined: 11 Nov 2010
Total Posts: 7345
31 May 2014 03:09 PM
When a ray is created, how long does it last for?

Would I have to use a loop to continuously make a new ray, or once the ray is created, it is permanent until I say otherwise?

Thanks.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
31 May 2014 03:12 PM
it doesn't "last" in any way
All it does is give you a position (and whatever part it hit) based on the arguments.

Yes you would have to loop
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