Pxkez
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 1066 |
|
|
| 12 Dec 2016 04:39 PM |
how would i use dot product to see if a part is infront of another part
~Help me u dirty cookie |
|
|
| Report Abuse |
|
|
Pxkez
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 1066 |
|
|
| 12 Dec 2016 04:43 PM |
( . Y . )
~Help me u dirty cookie |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Dec 2016 04:44 PM |
You can dot the lookVector to the direction from one to the other. I'll draw something up right now. |
|
|
| Report Abuse |
|
|
Pxkez
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 1066 |
|
|
| 12 Dec 2016 04:51 PM |
hllo?
~Help me u dirty cookie |
|
|
| Report Abuse |
|
|
Pxkez
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 1066 |
|
|
| 12 Dec 2016 04:58 PM |
bump
~Help me u dirty cookie |
|
|
| Report Abuse |
|
|
|
| 12 Dec 2016 05:00 PM |
If you define a certain range, for example 90 degrees, you can check if math.acos(p.CFrame.lookVector:Dot((p.Position-p1.Position).unit) and check if it's less than that angle in radians.
Remember: The dot product is really good for finding angles between vectors. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Dec 2016 05:00 PM |
puu.sh/sNouc/18513335de.mp4
And here's the code: pastebin/EYvbvpsC |
|
|
| Report Abuse |
|
|
Pxkez
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 1066 |
|
|
| 12 Dec 2016 05:08 PM |
@all thx <3
~Help me u dirty cookie |
|
|
| Report Abuse |
|
|
Soybeen
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 12 Dec 2016 05:52 PM |
| #### I don't understand what the green line indicates, is that the direction character A's head is facing? If so, then why does Someone Behind say true when B is clearly in front of A? It seems to flip when I don't expect it to. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 Dec 2016 06:34 PM |
The green line is the direction Head is facing, but I extended out to make things a bit more clear.
The message is not saying when either A or B is in front of each other, it's true when either one is in front of each other. If you want to make sure B is in front of A, you can just check if it's > 0.95 and behind if it's < -0.95. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
| |
|