|
| 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 |
|
|
| |
|
| |
|
|
| 23 Nov 2016 06:54 PM |
| by two angles, do you mean two vectors??? |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 06:58 PM |
| Can be two lookVectors or just convert into Angles. |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 07:00 PM |
| I don't understand how you are drawing it... tell me how you drew it |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 23 Nov 2016 08:22 PM |
Sorry for the wait, I was eating dinner at a restaraunt btw.
|
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 08:23 PM |
| ############################################################################################################################################################################################# |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 08:26 PM |
| Please rewrite that to avoid hashtags |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
| |
|
|
| 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 |
|
|
|
| 23 Nov 2016 08:32 PM |
_ / \ \ / _
prntscr db2e9s
Sorta like this? The player is in the middle of the red lines btw |
|
|
| Report Abuse |
|
|
|
| 23 Nov 2016 08:39 PM |
| Why not use basic linear algerbra |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|