I can’t get a hit on my game object when I am standing in the red debug laser, but if I move to the left, far from the debug draw line, I get a hit. This is vexing me
I got angry and named EVERYTHING “PlayerCube,” but that did not fix anything.
using UnityEngine;
using System.Collections;
public class Sight : MonoBehaviour {
public Transform ObjectEye;
Vector3 playerPosition;
Vector3 subjectPosition;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
Vector3 fwd = transform.TransformDirection(Vector3.forward);
playerPosition = transform.position;
subjectPosition = ObjectEye.position;
RaycastHit hit;
if (Physics.Raycast (transform.position, subjectPosition, out hit) && hit.transform.name == "PlayerCube") {
Debug.LogError ("poke");
}
Debug.DrawLine(transform.position, subjectPosition, Color.red);
}
}