Advertisement
Guest User

camera

a guest
May 28th, 2020
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class camera : MonoBehaviour
  6. {
  7. float speed = 3f;
  8. public Transform target;
  9.  
  10. // Start is called before the first frame update
  11. void Start()
  12. {
  13. transform.position = new Vector3(target.transform.position.x, target.transform.position.y, transform.position.z);
  14. }
  15.  
  16. // Update is called once per frame
  17. void Update()
  18. {
  19. Vector3 position = target.position;
  20. position.z = transform.position.z;
  21. transform.position = Vector3.Lerp(transform.position, position, speed * Time.deltaTime);
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement