So my camera throws a Raycast forward, and if this raycasts target hits a specified target, i want it to tell me. Very simple. Altough, it doesn't seem to always tell me when the target gets hit even though i can clearly see it does get hit. I do use Debug.DrawRay so there shouldn't be any problem.
I do have this theory that i need to hit the exact pivot point or middle point of the object, but that shouldn't be neccesary. Did i miss something here?
Here's the code.
Debug.DrawRay(transform.position, transform.forward * 100f, Color.green, 20);
if(Physics.Raycast(transform.position, transform.forward, out Target, PlayerReachRange) && Target.transform.tag == "MovableObject")
{
Debug.Log ("Shiggidiboo");
}
↧