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 » Scripters
Home Search
 

Re: Find if player is between two angles?

Previous Thread :: Next Thread 
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 05:59 PM
Is there a possible way to find if a player is positioned between two angles (on X and Z axis)? For example, if I have a lamp pointing towards the positive X axis and the light generated by the lamp, making a 90 degrees angle. The light has a ray of 30 studs. Sorry for my English and thank you in advance! :D
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 06:25 PM
Bump1
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 06:53 PM
Bump2
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 06:54 PM
by two angles, do you mean two vectors???
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 06:58 PM
Can be two lookVectors or just convert into Angles.
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 07:00 PM
I don't understand how you are drawing it... tell me how you drew it
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 07:01 PM
Like is the player looking at the lamp and the lamp light looking at the character making the hypotenuse, 30?
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 07:04 PM
If so I can calculate the x and y components for you, or I believe there's a :components() function you can use
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 07:10 PM
Oh, I think I explained it badly. I'll re-explain then.

Players are placed in an area shaped as a circle. If you cut this circle in 4 pieces, you have four 90 degrees arc of a circle. Take one them and remove the three others. From the center to the circumference, cut the arc in half and this line is the lookVector of the lamp.

From that line, you have an other line on the right side, 45 degrees from the center line and an other one to the left, -45 degrees away from the center line. The ray is 30 studs long.

Take all the players we had at the beginning (in the circle). Some of them are not in the arc. But how do I put them in a table, or find them? How could I script that? I don't know if I explained well this time... :/
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 07:12 PM
That was very well explained, hold on I have to do something so I can't respond right now
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 07:17 PM
I meant to put the players in the arc, not the ones that are not in the arc area. And sure, take your time. :P
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 08:04 PM
Bump :L
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 08:19 PM
Hold on, so you are figuring out how to detect if a player is near a lamp?
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 08:22 PM
Sorry for the wait, I was eating dinner at a restaraunt btw.

Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 08:23 PM
#############################################################################################################################################################################################
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 08:26 PM
Please rewrite that to avoid hashtags
Report Abuse
PleasantKillerman is not online. PleasantKillerman
Joined: 01 Nov 2011
Total Posts: 668
23 Nov 2016 08:27 PM
Roblox hashtags...

The .magnitude between two positions give the length.

The .unit between two positions give the lookVector (the angle)
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
23 Nov 2016 08:27 PM
_
/ \
| |
| |
\ /
_
Report Abuse
SoapyDishy is not online. SoapyDishy
Joined: 31 Aug 2015
Total Posts: 2169
23 Nov 2016 08:30 PM
Alright then just run checks to see if the players magnitude is 30 or less, and then if they have a lookvector that is nearly the same of the opposite of the lamp light lookvector.
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
23 Nov 2016 08:32 PM
_
/ \
\ /
_


prntscr
db2e9s

Sorta like this? The player is in the middle of the red lines btw
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
23 Nov 2016 08:39 PM
Why not use basic linear algerbra
Report Abuse
ScripterJohn13 is not online. ScripterJohn13
Joined: 01 Jan 2010
Total Posts: 5658
23 Nov 2016 08:46 PM
you could always compare the lookVector of your player with the unit direction of a vector from your player to the other player and use A dot B = || # ## || B || Cos(theta) and solve for theta.... that will give you angle between vectors directly though but it should put you in right direction...
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
23 Nov 2016 08:47 PM
prntscr\db2gnz

So subtract the Y values from your two vectors

next use Z as your 2D y

local pos = Vector3.new(-10,0,6)
local vector1 = Vector3.new(1,0,0)
local vector2 = Vector3.new(0,0,1)

if (pos * vector1).X < (pos * vector2).X then
print("X")
end
if (pos * vector1).Z < (pos * vector2).Z then
print("Y")
end


I honestly have no idea what im doing with this, however its a good start?
Report Abuse
MrJoeyJoeJoey is not online. MrJoeyJoeJoey
Joined: 20 Aug 2011
Total Posts: 20787
23 Nov 2016 08:50 PM
you could always compare the lookVector of your player with the unit direction of a vector from your player to the other player and use A dot B = || # ## || B || Cos(theta) and solve for theta.... that will give you angle between vectors directly though but it should put you in right direction...


ORR

You have four vectors

1. The circle to player
2. Circle to edge1
3. Circle to edge2
4. Circle to Circle (Constant)

Find the angle of all of these compared to Circle to Circle(0 degrees), and if the player is between edge1 and edge2 degrees

edge1 - 45
edge2 - 60
player - 50
-- OHH IT WORKS
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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