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: Is there anyway to check?

Previous Thread :: Next Thread 
RoQuick is not online. 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 is not online. 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 is not online. 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 is not online. OAuth2
Joined: 27 Nov 2016
Total Posts: 751
29 Sep 2017 10:09 AM
Wait, I lied.
Report Abuse
OAuth2 is not online. OAuth2
Joined: 27 Nov 2016
Total Posts: 751
29 Sep 2017 10:11 AM
<= 0*
Report Abuse
OAuth2 is not online. OAuth2
Joined: 27 Nov 2016
Total Posts: 751
29 Sep 2017 10:16 AM
yo im trippin

if check < 1 then*
Report Abuse
Shining_Diamando is not online. Shining_Diamando
Joined: 11 Oct 2014
Total Posts: 460
29 Sep 2017 10:29 AM
Unit dot product and compare to 0
Report Abuse
TheFishToucher is not online. TheFishToucher
Joined: 07 Jul 2012
Total Posts: 7995
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
Shining_Diamando is not online. Shining_Diamando
Joined: 11 Oct 2014
Total Posts: 460
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 is not online. 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
Shining_Diamando is not online. Shining_Diamando
Joined: 11 Oct 2014
Total Posts: 460
29 Sep 2017 03:43 PM
Do "print(torso.Position.unit:Dot(part.Position.unit))"

I forgot if it was > or <
Report Abuse
RoQuick is not online. 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 is not online. 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
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