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: Dot Product

Previous Thread :: Next Thread 
Pxkez is not online. 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 is not online. Pxkez
Joined: 24 Sep 2015
Total Posts: 1066
12 Dec 2016 04:43 PM
( . Y . )


~Help me u dirty cookie
Report Abuse
cntkillme is not online. 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 is not online. Pxkez
Joined: 24 Sep 2015
Total Posts: 1066
12 Dec 2016 04:51 PM
hllo?


~Help me u dirty cookie
Report Abuse
Pxkez is not online. Pxkez
Joined: 24 Sep 2015
Total Posts: 1066
12 Dec 2016 04:58 PM
bump



~Help me u dirty cookie
Report Abuse
xXIcanthinkofanameXx is not online. xXIcanthinkofanameXx
Joined: 05 May 2012
Total Posts: 857
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 is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
12 Dec 2016 07:06 PM
in front of the other*
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