I have this Script:
using UnityEngine;
using System.Collections;
public class PlayerRayCast : MonoBehaviour {
private Ray PlayerRay;
public static GameObject PlayerIsLookingAt;
public static RaycastHit PlayerRayCastHit;
// Use this for initialization
void Awake () {
PlayerRay = new Ray(GameObject.Find ("PlayerRaycastOrigin").transform.position, (GameObject.Find("PlayerRaycastDirection").transform.position - GameObject.Find("PlayerRaycastOrigin").transform.position));
}
void Update () {
Debug.DrawRay(GameObject.Find("PlayerRaycastOrigin").transform.position , (GameObject.Find("PlayerRaycastDirection").transform.position - GameObject.Find("PlayerRaycastOrigin").transform.position),Color.cyan, 0.02f );
if ( Physics.Raycast(PlayerRay ))
{
Debug.Log("Success");
}
Debug.Log("" + Physics.RaycastAll(PlayerRay, 1000000000f));
}
}
Physics.RayCastAll() does Fire, but Physics.RayCast does not, even though they’re using the same Ray. Also in Debug.Drawray clearly cuts through multiple Objects, so what could be the cause of it?