Version: 2017.1

Mathf.SmoothDampAngle

매뉴얼로 전환
public static float SmoothDampAngle (float current, float target, ref float currentVelocity, float smoothTime, float maxSpeed= Mathf.Infinity, float deltaTime= Time.deltaTime);

파라미터

current The current position.
target The position we are trying to reach.
currentVelocity The current velocity, this value is modified by the function every time you call it.
smoothTime Approximately the time it will take to reach the target. A smaller value will reach the target faster.
maxSpeed Optionally allows you to clamp the maximum speed.
deltaTime The time since the last call to this function. By default Time.deltaTime.

설명

Gradually changes an angle given in degrees towards a desired goal angle over time.

The value is smoothed by some spring-damper like function. The function can be used to smooth any kind of value, positions, colors, scalars. The most common use is for smoothing a follow camera.

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { public Transform target; public float smooth = 0.3F; public float distance = 5.0F; private float yVelocity = 0.0F; void Update() { float yAngle = Mathf.SmoothDampAngle(transform.eulerAngles.y, target.eulerAngles.y, ref yVelocity, smooth); Vector3 position = target.position; position += Quaternion.Euler(0, yAngle, 0) * new Vector3(0, 0, -distance); transform.position = position; transform.LookAt(target); } }