Newer
Older
TheVengeance-Project-IADE-Unity2D / Assets / Scripts / Camera / CameraController.cs
@Rackday Rackday on 29 Oct 607 bytes Major Update
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. public class CameraController : MonoBehaviour
  5. {
  6. public Transform target;
  7. public float smoothSpeed = 0.25f;
  8. private void Awake()
  9. {
  10. }
  11. void Start()
  12. {
  13. target = GameObject.FindGameObjectWithTag("Player").transform;
  14. }
  15. void FixedUpdate()
  16. {
  17. Vector3 targetPosition = new Vector3(target.position.x, target.position.y, -1f);
  18. Vector3 smoothedPosition = Vector3.Lerp(transform.position, targetPosition, smoothSpeed);
  19. transform.position = smoothedPosition;
  20. }
  21. }