RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
|
| 29 Sep 2017 09:12 AM |
is there anyway to check if a part is behind my player? I don't mean if its visible on my screen, I just need to know if its behind my player no matter the distance and still be able to see if its behind him even if he changes rotation
please help me, Ive tried hard and it seems impossible
|
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 29 Sep 2017 10:00 AM |
| I'll get back to you. Doing some testings right now. |
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 29 Sep 2017 10:06 AM |
local check = ((part.Position - Torso.Position).unit + Torso.CFrame.lookVector).magnitude if check < 1.5 then -- I did some testing. anything below 1.5 is considered behind i guess -- is behind |
|
|
| Report Abuse |
|
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
| |
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
| |
|
OAuth2
|
  |
| Joined: 27 Nov 2016 |
| Total Posts: 751 |
|
|
| 29 Sep 2017 10:16 AM |
yo im trippin
if check < 1 then* |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2017 10:29 AM |
| Unit dot product and compare to 0 |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2017 11:04 AM |
| use dot product to get angle formed by the lookvector of head and the vector (head.Position - Part.Position), if the absolute value of this angle is greater than (pi / 2) then it's behind |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2017 03:14 PM |
"use dot product to get angle formed by the lookvector of head and the vector (head.Position - Part.Position), if the absolute value of this angle is greater than (pi / 2) then it's behind" No, stop.
if (torso.Position.unit:Dot(part.Position.unit) < 0) then -- Behind
end; |
|
|
| Report Abuse |
|
|
RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
|
| 29 Sep 2017 03:40 PM |
thank you but I did this
repeat wait() until workspace:WaitForChild("RoQuick") local part = workspace.Test local torso = workspace:WaitForChild("RoQuick").Torso while wait(0.1) do if (torso.Position.unit:Dot(part.Position.unit) < 0) then print("BEHIND") else print("NOTBEHIND") end end
and it just says NOTBEHIND even though the part is behind me
please help! |
|
|
| Report Abuse |
|
|
|
| 29 Sep 2017 03:43 PM |
Do "print(torso.Position.unit:Dot(part.Position.unit))"
I forgot if it was > or < |
|
|
| Report Abuse |
|
|
RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
|
| 29 Sep 2017 03:44 PM |
I put print((torso.Position.unit:Dot(part.Position.unit) ))
and it just says NAN
please help! |
|
|
| Report Abuse |
|
|
RoQuick
|
  |
| Joined: 12 May 2013 |
| Total Posts: 595 |
|
|
| 29 Sep 2017 03:54 PM |
never mind it works the part.Position.unit just said NAN but once I moved the part, it worked
thank you |
|
|
| Report Abuse |
|
|