Advertisement
Guest User

Untitled

a guest
Jul 20th, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class TopDownFollow_Camera : MonoBehaviour {
  4.  
  5. public Transform FollowTarget;
  6. public Vector3 TargetOffset;
  7. public float MoveSpeed = 2f;
  8.  
  9. private Transform _myTransform;
  10.  
  11. private void Start () {
  12. // Cache camera transform
  13. _myTransform = transform;
  14. }
  15.  
  16. public void SetTarget ( Transform aTransform ) {
  17. FollowTarget = aTransform;
  18. }
  19.  
  20. private void LateUpdate () {
  21. if(FollowTarget != null)
  22. _myTransform.position = Vector3.Lerp( _myTransform.position, FollowTarget.position + TargetOffset, MoveSpeed * Time.deltaTime );
  23. }
  24.  
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement