Survival Shooter – Chapeter 3 – Camera

Change the camera to follow…

Go to MainCamera

Change X,Y,Z => 1, 15, -22

Rotation -> 30,0,0

Projection -> othographic with size 4.5

Background Color -> Black

 

Script time…

Create a script called CameraFollow and edit.


using UnityEngine;
using System.Collections;

public class CameraFollow : MonoBehaviour {
public Transform target;
public float smoothing = 5f;

private Vector3 offset;

void Start(){
offset = transform.position - target.position;

}
void FixedUpdate(){
Vector3 transformCamPos = target.position + offset;
transform.position = Vector3.Lerp (transform.position, transformCamPos, smoothing * Time.deltaTime);
}
}

<span style="line-height: 1.5;">

Make sure it compiles and drag/drop it into the camera object.