I want to calculate if a Ray that is launched from the Player head is hitting the Object’s pivot. Now the problem that I have is that the pivot isn’t a surface that can get hit right? Would it be possible to see if maybe a point of the ray matches the object’s pivot?
This is what I have so far:
var actorHead = Vector3 (transform.position.x, 1.6, transform.position.z);
var rayToPivot = (Player_Navigation.selectedObject.position - actorHead);
var hitPivot : RaycastHit;
var seePivot : boolean;
if (Physics.Raycast (actorHead, rayToPivot, hitPivot)) {
Debug.DrawLine (actorHead, hitPivot.point, Color.red);
if (hitPivot.transform.position == actorProperties.currentlySelectedObjProperties.transform.position && hitPivot.distance < 10.0 ) {
seePivot = true;
}
else {
seePivot = false;
}
}
Thanks for the help!
Hmm that would work I think, how would I go about checking if the point belongs to the line? I'm very new at scripting and my math skills are not that great....
– castor