Always Place an object in front of camera

Hi All,

I need to find at run-time at which direction camera is looking at.
So I thought to to place an object always in front of camera, irrespective of where the camera is currently looking at. E.g. If camera faces towards +x axis, then object should be placed in front of camera along the x axis.

I tried create a cube, make it child of camera and place it at some distance d in front of camera, but as camera moves, child object doesnt move.

I have searched a lot but could not find anything related. I am not planning to attach any Rigidbody component with the object.

Please someone help me out!

If this is a duplicate question then please point me to the thread but please please dont close this thread as I need to solve it urgently.

Thanks in advance!!!

You can either add the object as a child of the object, or you can have a script as follows:

void Update()
{
   transform = Camera.main.transform;
   transform.position.z = Camera.main.transform +5 ;
}