SmoothFollow.cs 440 B

12345678910111213141516
  1. using UnityEngine;
  2. namespace Lux_SRP_GrassDisplacement
  3. {
  4. public class SmoothFollow : MonoBehaviour {
  5. public Transform targetTransform;
  6. public float smoothTime = 0.15F;
  7. private Vector3 velocity = Vector3.zero;
  8. void Update() {
  9. Vector3 targetPosition = targetTransform.position;
  10. transform.position = Vector3.SmoothDamp(transform.position, targetPosition, ref velocity, smoothTime);
  11. }
  12. }
  13. }