Camera to follow an instantiated moving object

I have a moving rigidbody object that is instantiated on a click and I have a camera with smooth follow (SmoothFollow.js) that is supposed to follow the object. Applying the object prefab as the target for smooth follow does not work. The target is found, but the camera is immobile and in a wrong place. It would be great if someone could give me some ideas on how to implement this.

Can you post the instantiation code and the code that links the camera to the object? From your story it sounds like you’re incorrectly linking the camera to the prefab and not to the instance, but it’s difficult to tell without the code.

what u can do , is just let the smoothfollow script as it is and add this :

add a static varriable so u can access to it from outside , and let the “target” varriable already exist in the “SmoothFolow.js”

add this line just after the LateUpdate() line in the script, that will change the new object , so the code should be like this

u can access to ur new target from anywhere by :
SmoothFollow.new_target ;

Thank you both for the quick responses.

I did what crazyosachou suggested and the camera works now. I may need to tweak this later anyway, so a quick fix like this is just what the doctor ordered.

Sorry, is the script that Mr Crazy supplied meant to be added to the SmoothFollow.js? The SmoothFollow.js function is already a LateUpdate so I declared the static var and added the line to it and now the camera jumps to a seeming random (although the same each time) spot high in the sky looking down.