Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class CameraController : MonoBehaviour {
- public float speed = 1;
- public Transform Target;
- public Camera cam;
- // Update is called once per frame
- void LateUpdate () {
- Move ();
- }
- public void Move()
- {
- Vector3 direction = (Target.position - cam.transform.position).normalized;
- Quaternion lookrotation = Quaternion.LookRotation (direction);
- lookrotation.x = transform.rotation.x;
- lookrotation.z = transform.rotation.z;
- transform.rotation = Quaternion.Lerp (transform.rotation, lookrotation, Time.deltaTime * 100);
- transform.position = Vector3.Lerp (transform.position, Target.position, Time.deltaTime * speed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement