Camera following Bullet

Hi, im making a FPS game, but when i shoot i want the camera starts following the object, like bullet time in matrix, i’ve tried a lot of “answers” with similar topics at this site, but i cant get it to work, here is the code where i create the bullet:

var bullet:GameObject;
var sound1: AudioClip;


function Start () {


}

function Update () {

	if(Input.GetButtonDown("Fire1")){
		audio.PlayOneShot(sound1);
		var bulletInstance:GameObject = Instantiate(bullet,transform.position,Quaternion.identity);
	
		
		
		Physics.IgnoreCollision(transform.root.collider , bulletInstance.collider);
		
		bulletInstance.rigidbody.AddForce(
		Camera.mainCamera.transform.TransformDirection(Vector3(0,0,100))
		,ForceMode.Impulse);
		
		
        
        
		
	}

}

thanks!

The way I do it is add another camera to the scene then child the bullet model you have to it then save the camera as the bullet prefab ready to Instantiate as your bulletInstance.

Then put 2 new variables at the top of your script -

var Camera2 : Camera;
private var Camera1 : Camera;

Drop your bullet prefab into the Camera2 slot in the Inspector, then in the Start function add -

Camera1 = Camera.main;

Then when you fire your bullet add -

Camera1.enabled = false;
Camera2.enabled = true;

Then add a script to your bullet prefab with the reverse -

Camera1.enabled = true;
Camera2.enabled = false;

Triggered on collision of the bullet.

Hope this helps.