-
-
Save JT5D/c3e2909d03ab6937563e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using UnityEngine; | |
| using System.Collections; | |
| public class dottest : MonoBehaviour { | |
| public Transform p1; | |
| public Transform p2; | |
| public Transform p3; | |
| public GUIText guiDOT; | |
| void Update () | |
| { | |
| Vector3 perpendicular = Vector3.Cross(p1.position-p2.position,Vector3.forward); | |
| Vector3 targetDir = (p3.position-p1.position); | |
| Debug.DrawLine(p1.position,p2.position,Color.gray); | |
| Vector3 midpoint = Vector3.Lerp(p1.position,p2.position,0.5f); | |
| Debug.DrawLine(midpoint,midpoint+perpendicular.normalized,Color.white); | |
| float dotVal = Vector3.Dot(perpendicular.normalized,targetDir.normalized); | |
| if (dotVal<0) | |
| { | |
| Debug.DrawLine(p1.position,p3.position,Color.red); | |
| Debug.DrawLine(p2.position,p3.position,Color.red); | |
| }else{ | |
| Debug.DrawLine(p1.position,p3.position,Color.green); | |
| Debug.DrawLine(p2.position,p3.position,Color.green); | |
| } | |
| guiDOT.text = "DOT: "+dotVal; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment