Advertisement
Guest User

Untitled

a guest
Apr 26th, 2018
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. public class CameraScript : MonoBehaviour {
  2.  
  3. public Transform playerTransform;
  4. private Vector2 velocity;
  5. public float smooth;
  6.  
  7. // Use this for initialization
  8. void Start () {
  9. velocity = new Vector2 (0.5f, 0.5f);
  10. }
  11.  
  12. // Update is called once per frame
  13. void LateUpdate () {
  14. Vector3 newPosition = Vector3.zero;
  15.  
  16. newPosition.x = Mathf.SmoothDamp (transform.position.x, playerTransform.position.x,
  17. ref velocity.x, smooth);
  18.  
  19. newPosition.y = Mathf.SmoothDamp (transform.position.y, playerTransform.position.y,
  20. ref velocity.y, smooth);
  21.  
  22. newPosition.z = transform.position.z;
  23.  
  24. transform.position = Vector3.Slerp (transform.position, newPosition, Time.time);
  25. }
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement