Center camera on object in unity3d by programatically (87474)

i wanted to center my camera on object once they are turn is active.. But, i am unable to do it.

Here is my code:

public GameObject UserPlayerPrefab;
public Vector3 v3;

void Update()
    {
        transform.LookAt(UserPlayerPrefab);
    }

i already tried that, but it gave me the error, said that i have to use Vector3. When i change the code to this one:

void Update()
        {
            transform.LookAt(v3);
        }

it works, but not the camera is not center on the object however it is center on the Tile (which is the Plane).

How do i fix it? Thanks

If you don’t initialize v3, its default values are (0,0,0) which will make your camera look at that position. Use transform.LookAt(UserPlayerPrefab.transform.position);