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
 

How to raycast a field of view?

Previous Thread :: Next Thread 
ScriptOn is online. ScriptOn
Joined: 22 Aug 2010
Total Posts: 10885
27 Dec 2013 10:31 AM
Suppose I wanted to see if a raycast could reach another object without hitting it, but only within certain field of view. Like this: twitter.com/ScriptOnRoblox/status/416606961568710657/photo/1

Sorry if twitter links aren't allowed, but I don't know how else to show it.

Any ideas?
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Dec 2013 10:32 AM
"without hitting it"

Isn't that what you need to do to see if it's within range?
Report Abuse
ScriptOn is online. ScriptOn
Joined: 22 Aug 2010
Total Posts: 10885
27 Dec 2013 10:34 AM
Its for a claymore script.

I want the center of the claymore to only blow up if:

A. There is a person within its field of view
B. They are close enough
C. Nothing is in between them
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Dec 2013 10:35 AM
Ray.new(start, (lookAt - start).unit*range)

try that
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Dec 2013 10:37 AM
Then use FindPartOnRay to check if there is anything between the start and the lookAt (lookAt = the player, I think). Remember, FindPartOnRay gets the FIRST part to hit the ray, so if it's not the player, there's something in between.
Report Abuse
ScriptOn is online. ScriptOn
Joined: 22 Aug 2010
Total Posts: 10885
27 Dec 2013 10:46 AM
evolve, all that "range" thing does is set the max distance of the ray, not the angles it can go by.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Dec 2013 10:47 AM
Oh, well then send a bunch of angled rays.
Report Abuse
evolvedpikachu is not online. evolvedpikachu
Joined: 18 Aug 2010
Total Posts: 10696
27 Dec 2013 10:49 AM
http://wiki.roblox.com/index.php/CFrame#Methods

Use some of these to rotate object stuff to world stuff (or maybe the other way around?) and then do a bunch of adding and subtracting.
Report Abuse
ScriptOn is online. ScriptOn
Joined: 22 Aug 2010
Total Posts: 10885
27 Dec 2013 10:50 AM
lol no, but thanks anyways.

I think what I`m going to do is clone the part that is facing the object, then put the clones CFrame as the rays, and check the parts rotation.X against the original Rotation.X. If the difference is over 30, then cancel firing. >:D
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