Raycast doesn't seem to register a collision

What the code below does is simply attach `pickUpObject` to the parent transform (in this case, a first person controller) on a press of control and if the ray cast intersects with the box within 100 units. The `pickUpObject`is assigned in the Inspector and that object has a box collider on it. However, the Debug.Log() never triggers.

    using UnityEngine;
using System.Collections;

public class PressedLogic : MonoBehaviour
{
public Transform pickUpObject;
private bool pickedUp = false;

// Update is called once per frame
void Update()
{
    Vector3 fwd = transform.TransformDirection(Vector3.forward);
    if (Input.GetKeyDown(KeyCode.LeftControl) && Physics.Raycast(transform.position, fwd, 100))
    {
        if (!pickedUp) //Are we holding something?
        {
            Debug.Log("Ray hit, and we aren't holding anything");
            pickUpObject.position = transform.TransformPoint(Vector3.forward);
            pickUpObject.parent = transform;
            pickedUp = true;
        }
        else if (pickedUp)
        {
            pickedUp = false;
            pickUpObject.parent = null; //No parent, so it sets it back to root hierachy
        }
    }

}

}

ive had problems with trying to do a raycast along with another condition inside an if statement. try the raycast in its own if statement

I had a similar problem when trying to register a raycast onto a collider. I found that my collider was a bit bigger than the object and that it was getting culled by the near clipping plane and not registering.

Just a thought but maybe this is your problem?