I have an object moving around, with a large sphere collider, that if the first person controller triggers, the player is locked down and the object moves toward it. I’d like to do a ray cast first to find out if it is the correct collider or not, as there will be a spherical collider on the player and the walls will have box colliders, this snippet of code has not worked, how can I do this correctly?
var characterPos : Vector3;
var sensorPos : Vector3;
var journeyLength : float;
characterPos = GameObject.Find("FirstPersonController").transform.position;
sensorPos = GameObject.Find("Cube").transform.position;
var hit : RaycastHit;
if (Physics.Raycast (transform.position, sensorPos, hit)) {
if(hit.collider == BoxCollider)
{
Debug.Log("WOOT")
}